带计时器的可执行 jar
我编写了一个带有两个运行小动画的计时器的程序。最初,timerX 运行时间为 5ms,timerY 运行时间为 1ms。我将程序导出到可执行 jar 文件,一切正常。然后我将罐子发送到另一台运行相同规格的计算机,再次没有出现任何问题。然而,我决定加快timerX的速度,因此我将这个计时器更改为以1ms运行,运行、保存并导出文件。从我的桌面上,这个新文件运行得很好,但是当将其传递到另一台计算机时,与之前的文件相比没有任何变化。在将其重新发送到可执行 jar 文件之前,我需要在 eclipse 中执行某些操作吗?另外,为什么它在我的桌面上运行良好,但在另一台计算机上却运行不佳——同样设置为 1 毫秒的第二个计时器在这两种情况下运行得同样快。
I wrote a program with two timers running small animations. Originally timerX was running at 5ms and timerY was running a 1ms. I exported the program to an executable jar file and everything worked fine. I then sent the jar to another computer running the same specs and again there were no problems. However, I decided to speed up timerX, so I changed this timer to run at 1ms, ran, saved and exported the file. From my desktop this new file ran perfectly but when passing it to the other computer there was no change from the previous one. Is there something I need to do in eclipse before I resend it to the executable jar file? Also why is it running fine from my desktop but not on the other computer - the second timer which is also set at 1ms runs equally fast in both instances.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如定时器精度所示,时钟分辨率取决于主机平台和操作系统。虽然
javax.swing.Timer
默认情况下会合并事件,定时器线程往往会在如此短的周期(高频率)下快速饱和。您可能需要对旧系统进行补偿。As shown in Timer accuracy, clock resolution depends on the host platform and operating system. Although
javax.swing.Timer
will coalesce events by default, the timer thread will tend to saturate quickly with such a short period (high frequency). You may need to compensate on older systems.