Scorcher84
Scorcher84

Reputation: 423

What is the best way to call repaint() at regular intervals in my Java2D program?

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?

Upvotes: 0

Views: 927

Answers (2)

ArK
ArK

Reputation: 21068

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

and this may useful for you efiicient way to repaint

Upvotes: 2

camickr
camickr

Reputation: 324118

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

Upvotes: 1

Related Questions