Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.glorb.com!news-out.readnews.com!news-xxxfer.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail From: "Lew" Subject: Re: How to refresh UI imm Message-ID: X-Comment-To: comp.lang.java.gui Newsgroups: comp.lang.java.gui In-Reply-To: <4b7ec1b0-c2f8-4709-9980-e25508797548@r66g2000hsg.googlegroups.co References: <4b7ec1b0-c2f8-4709-9980-e25508797548@r66g2000hsg.googlegroups.co Content-Type: text/plain; charset=IBM437 Content-Transfer-Encoding: 8bit X-Gateway: time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92] Lines: 28 Date: Wed, 27 Apr 2011 15:46:11 GMT NNTP-Posting-Host: 96.60.20.240 X-Complaints-To: news@tds.net X-Trace: newsreading01.news.tds.net 1303919171 96.60.20.240 (Wed, 27 Apr 2011 10:46:11 CDT) NNTP-Posting-Date: Wed, 27 Apr 2011 10:46:11 CDT Organization: TDS.net Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.gui:3661 To: comp.lang.java.gui mrstephengross wrote: > I have a combobox with an ActionListener. When you select an item, it > fires off a process that can take a few seconds to execute. I have > found that when you click your selection, it fires the process but > does not immediately close the combo box. That is, it waits until the > process is done running before closing the combobox. > > Is there a way to change this behavior? I would like to close the > combobox immediately after an item in it is selected and then fire off > the process. What you have experienced is the Dark Side of the Event Dispatch Thread (EDT). The GUI all runs in its own thread, the EDT. You also apparently ran the process on the same thread. (Guessing, since you declined to provide an SSCCE.) What you need is something like the SwingWorker class to move the hard work off to an independent thread, then the GUI can get right back to its refresh immediately. See the Sun Swing tutorial for details. -- Lew --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24