Swing: passing value back to user interface from scheduled thread

I have a user interface in the Java system tray that requires polling the schedule database. What is the best method for spawning a new thread and notifying the user interface?

I am new to Swing and it is a streaming model.

+3
source share
3 answers

SwingWorker - this is what is intended for this.

It allows you to run a task that will not block the GUI, and then return the value and update the GUI when it is done.

Java has a great tutorial on how to use SwingWorker.

, doInBackground(). done() .

+6

jinguy, SwingWorker , . Wikipedia, , , , JavaDocs.

+5

jjnguy, SwingWorker , , , . SwingWorker, SwingUtilities ( EventQueue).invokeLater(Runnable).

-. Swing ( ) , . , (, , ).

+2
source

Source: https://habr.com/ru/post/1713786/


All Articles