Re: How to refresh UI immediately?
- From: Roedy Green <see_website@xxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 18 Jun 2008 19:46:27 GMT
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
.
- References:
- How to refresh UI immediately?
- From: mrstephengross
- How to refresh UI immediately?
- Prev by Date: Re: Repainting and threading - the eternal problem...
- Next by Date: Re: Newbie: How to find out installed version of java?
- Previous by thread: Re: How to refresh UI immediately?
- Index(es):
Relevant Pages
|