Re: Using Thread.sleep(..) and Swing Components
- From: RedGrittyBrick <RedGrittyBrick@xxxxxxxxxxxxxxxxx>
- Date: Mon, 29 Sep 2008 19:37:40 +0100
Peter Duniho wrote:
On Mon, 29 Sep 2008 10:30:37 -0700, <karpthomas@xxxxxxxxxxxxxx> wrote:
[...]
The problem is, that the component seems to be repainted only, when the method
is finished.
What am I doing wrong?
You are delaying the event-dispatch thread by calling sleep().
Operations that take any significant amount of time should be handled on a different thread, using the EventQueue.invokeLater() and EventQueue.invokeAndWait() methods to execute any code that is required to be executed on the EDT (such as setting the value of a progress bar control).
I find SwingWorker useful too. It simplifies the work of creating and using threads when you also want to update the GUI.
Just my ¤0.02 worth
--
RGB
.
- Follow-Ups:
- Re: Using Thread.sleep(..) and Swing Components
- From: John B. Matthews
- Re: Using Thread.sleep(..) and Swing Components
- From: karpthomas
- Re: Using Thread.sleep(..) and Swing Components
- References:
- Using Thread.sleep(..) and Swing Components
- From: karpthomas
- Re: Using Thread.sleep(..) and Swing Components
- From: Peter Duniho
- Using Thread.sleep(..) and Swing Components
- Prev by Date: Struts for swing
- Next by Date: Re: Java Generics and Erasure foobar
- Previous by thread: Re: Using Thread.sleep(..) and Swing Components
- Next by thread: Re: Using Thread.sleep(..) and Swing Components
- Index(es):
Relevant Pages
|