Java Swingworker: Not as encapsulated class

Posted by Thomas Matthews on Stack Overflow See other posts from Stack Overflow or by Thomas Matthews
Published on 2010-04-23T23:24:51Z Indexed on 2010/04/24 0:23 UTC
Read the original article Hit count: 597

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?

  1. 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.}

© Stack Overflow or respective owner

Related posts about java

Related posts about swingworker