Threads in Swing

Anyone know how to using Thread.sleep() after all the Swing component being painted? What my program does before is it will perform execute the Thread.sleep() first before painting the component. I am expecting it paint first then execute the Thread.sleep()
[264 byte] By [mythinkya] at [2007-10-1 7:15:38]
# 1
Eh, what?Why do you want to sleep in paint? That will block the awt thread.
kajbja at 2007-7-9 18:23:29 > top of Java-index,Java Essentials,Java Programming...
# 2
I want to paint during runtime. The painting will paint for many times with a specified delay each painting. U mean we can't use Thread in swing?
mythinkya at 2007-7-9 18:23:29 > top of Java-index,Java Essentials,Java Programming...
# 3
You should not sleep in the paint method since it is called by the thread that is responsible for painting. You should instead create another thread that sleeps and calls repaint./Kaj
kajbja at 2007-7-9 18:23:29 > top of Java-index,Java Essentials,Java Programming...
# 4
Read this url: http://java.sun.com/products/jfc/tsc/articles/painting/index.html/Kaj
kajbja at 2007-7-9 18:23:29 > top of Java-index,Java Essentials,Java Programming...
# 5

> You should not sleep in the paint method since it is

> called by the thread that is responsible for

> painting. You should instead create another thread

> that sleeps and calls repaint.

Seperate the model from the view and it gets repainted automatically when it was changed... as long as you don't need a *very* exact timing, there shouldn't be a need to call repaint. Just wait for the next cycle.

CeciNEstPasUnProgrammeura at 2007-7-9 18:23:29 > top of Java-index,Java Essentials,Java Programming...
# 6

> Seperate the model from the view and it gets

> repainted automatically when it was changed... as

> long as you don't need a *very* exact timing, there

> shouldn't be a need to call repaint. Just wait for

> the next cycle.

I might be wrong here, but I thought we were talking about creating animations :)

kajbja at 2007-7-9 18:23:29 > top of Java-index,Java Essentials,Java Programming...
# 7
> I might be wrong here, but I thought we were talking> about creating animations :)I thought it was about some data being updated periodically...
CeciNEstPasUnProgrammeura at 2007-7-9 18:23:29 > top of Java-index,Java Essentials,Java Programming...
# 8
I think you are correct. I don't know why I first thought about animations when I saw the post. Could have been because of the sleep in paint.
kajbja at 2007-7-9 18:23:29 > top of Java-index,Java Essentials,Java Programming...
# 9
> I think you are correct. I don't know why I first> thought about animations when I saw the post. Could> have been because of the sleep in paint.Not that it makes too much of a difference for the solution. :)
CeciNEstPasUnProgrammeura at 2007-7-9 18:23:29 > top of Java-index,Java Essentials,Java Programming...