I trust you know why that is incorrect? You should not use more than one thread for a Swing app like that. You should use a Timer.Alex Chun wrote: . . . The ball should be updated using a Runnable (3 Points).
. . .
Nonononononono.Alex Chun wrote:
Campbell Ritchie wrote:(...)I trust you know why that is incorrect? You should not use more than one thread for a Swing app like that. You should use a Timer.
You have gone one worse, I am afraid. You have neither taken the standard route of running everything on the EDT and using a Timer, nor the incorrect route in the question. You have called sleep() on the current thread. All you achieve like that is freezing the display. Since the sleep() call is short, the 5ms delay may be less than the time it takes to repaint your display. At the moment it seems you are getting away with it.
There are three kinds of actuaries: those who can count, and those who can't.
Or believe they ought to be taught to do things right.Piet Souris wrote: . . . Either my remarks were unclear or
you don't believe what I wrote, . . .
There are three kinds of actuaries: those who can count, and those who can't.
Yes, that would appear to be the case.Piet Souris wrote: . . .
My impression is also that this is an assignment OP has to fullfill, and that he must
use a Runnable (that must use Thread.sleep ;))))
. . .
Don't get me started about those stupid light bulbs. |