Computer Science Canada repaint not working in JFrame |
Author: | gsquare567 [ Thu Apr 10, 2008 8:16 am ] | ||
Post subject: | repaint not working in JFrame | ||
i want it to repaint after waiting 50 milliseconds, but the frame will not repaint. stars (********) are next to it.
|
Author: | OneOffDriveByPoster [ Thu Apr 10, 2008 11:42 am ] | ||
Post subject: | Re: repaint not working in JFrame | ||
The repaint() will not call paint() until after you are finished your random walking loop. IIRC the callbacks are called from the same thread so doRandomWalk() and paint() will not run at the same time (unless if one calls the other). A bad solution (force paint)
|
Author: | gsquare567 [ Mon Apr 14, 2008 9:17 am ] |
Post subject: | RE:repaint not working in JFrame |
i love you |
Author: | three0s [ Mon May 21, 2012 8:15 pm ] | ||
Post subject: | Re: repaint not working in JFrame | ||
OneOffDriveByPoster @ Thu Apr 10, 2008 11:42 am wrote: The repaint() will not call paint() until after you are finished your random walking loop. IIRC the callbacks are called from the same thread so doRandomWalk() and paint() will not run at the same time (unless if one calls the other).
A bad solution (force paint)
Thanks. The bad solution is really a good solution in terms of making the program work. |
Author: | md [ Tue May 22, 2012 6:18 pm ] |
Post subject: | RE:repaint not working in JFrame |
The better solution would be to use a Swing timer in order to call doRandomWalk() which would perform one random step, draw, and then return. It is usually a bad idea to perform long running calculations or attempt to implement your own frame-rate stuff in the Swing UI thread. |