Re: How to refresh UI immediately?
- From: Lew <conrad@xxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 17 Jun 2008 23:33:00 -0400
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
.
- References:
- How to refresh UI immediately?
- From: mrstephengross
- How to refresh UI immediately?
- Prev by Date: Re: How to refresh UI immediately?
- Next by Date: Re: How to refresh UI immediately?
- Previous by thread: Re: How to refresh UI immediately?
- Next by thread: Re: How to refresh UI immediately?
- Index(es):
Relevant Pages
|