Java – swing: pass values back to the UI from a predetermined thread
•
Java
I have a java system tray UI and need a scheduled database polling What is the best way to generate a new thread and notify the UI?
I am a novice of swing and its thread model
Solution
Swing worker is designed for this purpose
It allows you to run tasks that do not block the GUI, then return a value and update the GUI when finished
Java has a great tutorial on how to use swingworker
Basically, the database is pulled into the doinbackground () method Also, in the done () method, update your GUI
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码