CountDown
DescriptionCountDown is a simple demonstration of how to animate a drawing
when a recursive method is involved. It is more complicated than other sorts
of animation because if the recursive method just runs, only the final step of
the animation will show. Thus, we need a way to slow it down.
One might think using the following would work:
try { Thread.sleep(500); }
catch (InterruptedException e){ }
However, this will not work if there are Swing/AWT components involved.
For instance, if you click a button to make the animation start, the entire
recursive method must finish executing before the button "unclicks"
and the GUI updates. Thus, you get no animation.
The solution is to create a new Thread which executes the recursive
method.
The JAR file is executable and contains BlueJ project files.
|