Re: How to refresh UI immediately?



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
.



Relevant Pages

  • Re: have problems with divs
    ... You need to set up your forms so that when a user makes a selection or changes a selection ... Each time the script fires, it will then rewrite those items to the table. ... it would only run once as it is witin a HTML file. ... > Your browser does not support inline frames or is currently configured not ...
    (microsoft.public.frontpage.programming)
  • Re: IE automation
    ... Fires when the user aborts the download of an image. ... Fires on the source object before the selection is copied to the system ... Fires on the target element when the user drags the object to a valid drop ...
    (microsoft.public.vc.mfc)
  • Re: non-firing Form_Current on new record selected by listbox
    ... Form_Current event fires on opening the form (1st record is selected by ... default) and fires on the selection of all records selected via the ListBox ... Typical record navigation code is ...
    (microsoft.public.access.formscoding)
  • Re: How to refresh UI immediately?
    ... fires off a process that can take a few seconds to execute. ... found that when you click your selection, ... for general hints on how to spawn threads. ...
    (comp.lang.java.gui)
  • Re: Menustrip strange behavior (.NET2)
    ... In XP/Office/VS, a menu when is opened, moving mouse with left button pressed allows selection of menu items. ... Releasing left button over an item fires the clicked event. ...
    (microsoft.public.dotnet.framework.windowsforms.controls)