gpt4 book ai didi

java - 在 Swing 外使用 Swing 计时器可以吗?

转载 作者:塔克拉玛干 更新时间:2023-11-01 22:45:36 24 4
gpt4 key购买 nike

正如标题所说,在非 swing 应用程序中使用 swing 定时器是否可以接受?

或者我最好使用单独的线程编写自己的线程?

我不知道 Swing 计时器可能有什么缺点,但我倾向于使用已经存在的东西。

最佳答案

In general, we recommend using Swing timers rather than general-purpose timers for GUI-related tasks because Swing timers all share the same, pre-existing timer thread and the GUI-related task automatically executes on the event-dispatch thread. However, you might use a general-purpose timer if you don't plan on touching the GUI from the timer, or need to perform lengthy processing.

文档:http://docs.oracle.com/javase/tutorial/uiswing/misc/timer.html

我应该推荐使用 util.Timer

关于java - 在 Swing 外使用 Swing 计时器可以吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25671527/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com