且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Java JTable每2秒刷新一次

更新时间:2023-12-03 13:11:28

javax.swing.Timer 对此有点尴尬; as java.util.Timer 。只要您在 TableModel =nofollow noreferrer>事件调度线程,您可以使用下面引用的任一方法每两秒在另一个线程上查询数据库。请注意,可以在后台线程上休眠。

A javax.swing.Timer is a little awkward for this; as is java.util.Timer. As long as you update your TableModel on the event dispatch thread, you can query the database on another thread every two seconds using either approach cited below. Note that it's OK to sleep on a background thread.

Runnable ,见此处