Yes. From the background thread - both regular threads and SwingWorker.doInBackground you should not change the user interface to avoid various problems.
Instead, wrap the changes in Runnable and execute them in EDT using SwingUtilities.invokeAndWait , SwingUtilities.invokeLater or — when using SwingWorker — through publish (from doInBackground ). As part of the process SwingWorker method that EDT runs, you can access the graphical interface.
http://docs.oracle.com/javase/tutorial/uiswing/concurrency/initial.html
Personally, I find invokeLater and invokeAndWait easier to use for many situations. SwingWorker is fine, for example. progress indicators.
Anony-mousse
source share