开发者

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

开发者 https://www.devze.com 2022-12-09 00:43 出处:网络
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 cu

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?


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

and this may useful for you efiicient way to repaint


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

0

精彩评论

暂无评论...
验证码 换一张
取 消