Java Swingworker: Not as encapsulated class
- by Thomas Matthews
I'm having problems passing information, updating progress and indicating "done" with a SwingWorker class that is not an encapsulated class.
I have a simple class that processes files and directories on a hard drive. The user clicks on the Start button and that launches an instance of the SwingWorker.
I would like to print the names of the files that are processed on the JTextArea in the Event Driven Thread from the SwingWorker as update a progress bar. All the examples on the web are for an nested class, and the nested class accesses variables in the outer class (such as the done method). I would also like to signal the Event Driven Thread that the SwingWorker is finished so the EDT can perform actions such as enabling the Start button (and clearing fields).
Here are my questions:
1. How does the SwingWorker class put text into the JTextArea of the Event Driven Thread and update a progress bar?
How does the EDT determine when the {external} SwingWorker thread is finished?
{I don't want the SwingWorker as a nested class because there is a lot of code (and processing) done.}