Forums Register Login

Pausing for "animation"

+Pie Number of slices to send: Send
I want to be able to show a set of pictures that would result in a primitive sort of animation. I'd like to do something lighter than making my thread sleep. Is there a way to pause the code without pausing the thread, other than something like a for-next loop of 1 to 2000 just to take up time? Thanks.
+Pie Number of slices to send: Send
Yes look at the Timer classes. I think there are two one in java.util and one in javax.swing I think. (I would look it up but am on the phone now). You would use one of those to schedule a change to happen at some defined interval, and provide a task to execute at that interval.
+Pie Number of slices to send: Send
Beware: Last time I tried anything big in Swing, it took something like 30ms for the display to repaint itself. Which means that running the Timer every 20ms may result in frames being missed out. Computer have got a lot faster since then, so that problem may not apply any more.

I think it will be the Swing timer you want. There are actually three Timers in the Java7 API. That is the bad news. The good news, however, is that the Java Tutorials tells you all about Swing timers.
+Pie Number of slices to send: Send
Thanks for the responses. This is helpful.
+Pie Number of slices to send: Send
You're welcome
You may have just won ten million dollars! Or, maybe a tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 513 times.
Similar Threads
Animation pause button
threading in javascript
pause a progam
Multimedia+Applet
How to improve the performance of my animation?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 13:54:46.