在Java2D程序中定期调用repaint()的最佳方法是什么? [英] What is the best way to call repaint() at regular intervals in my Java2D program?
本文介绍了在Java2D程序中定期调用repaint()的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望定期在Java2D模拟器中调用repaint().
I'm looking to call repaint() in my Java2D simulator at regular intervals.
什么是最好的方法?我应该启动另一个线程并有一个跟踪currentTimeMillis()的循环吗?还是有更好的方法?
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?
推荐答案
在Java中使用计时器功能( javax.swing.Timer )
Use timer function in java (javax.swing.Timer)
,这可能对您有用重新粉刷的有效方法
这篇关于在Java2D程序中定期调用repaint()的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文