tags:

views:

80

answers:

2

I'm looking to call repaint() in my Java2D simulator at regular intervals.

What would be the best way to do this? Should I start another thread and have a loop that keeps track of currentTimeMillis()? Or is there a better way?

A: 

Use a Timer. If its a Swing application use a Swing Timer. If its AWT then use TimerTask.

camickr
Swing's `Timer` works fine for AWT. With `java.util.Timer` you would need to do the `invokeLater` yourself.
Tom Hawtin - tackline
+2  A: 

Use timer function in java (javax.swing.Timer)

and this may useful for you efiicient way to repaint

Paniyar