Re: How to refresh UI immediately?



On Tue, 17 Jun 2008 18:07:41 -0700 (PDT), mrstephengross
<mrstevegross@xxxxxxxxx> wrote, quoted or indirectly quoted someone
who said :

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.

The way to handle it is to spawn a background thread in your
ActionListener to actually do the work. You should never tie up the
Swing thread for more that a few milliseconds, otherwise your whole
GUI becomes unresponsive.

For examples of the technique see:
http://mindprod.com/jgloss/products1.html#SUBMITTER
http://mindprod.com/jgloss/products1.html#VERCHECK
http://mindprod.com/jgloss/products1.html#REPLICATOR (in the client
side)

See http://mindprod.com/jgloss/thread.html
for general hints on how to spawn threads.

This is probably not tricky. There won't be any synchronisation.
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
.



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, ... 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. ...
    (comp.lang.java.gui)
  • Menustrip strange behavior (.NET2)
    ... pressed allows selection of menu items. ... Releasing left button over an item ... fires the clicked event. ...
    (microsoft.public.dotnet.framework.windowsforms.controls)