开发者

How can I refresh a view every second to reflect changes in real time?

开发者 https://www.devze.com 2023-02-07 06:29 出处:网络
I\'m writing an app for a manager to keep track of the goings-on of a factory that uses machines. Could I make a Swing interface that updates from an SQL database and constantly shows who is logged in

I'm writing an app for a manager to keep track of the goings-on of a factory that uses machines. Could I make a Swing interface that updates from an SQL database and constantly shows who is logged into each machine, the status of each machine and 开发者_StackOverflow中文版how many things are in the queue of each machine? All the machine info is in the database.

In short, how can I refresh a view every second so that it will reflect the real-time status of the factory floor?


Using the Java timer class at 1000 milliseconds and querying the mysql database. Provided your db latency is low, you should be able to update 1/second.


Or use a ScheduledExecutorService

0

精彩评论

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