I use javax.swing.SwingWorkerfor the first time.
I want to update JLabelfrom intermediate results published by Swing Worker as follows:
publish("Published String");
Now, to update JLabel, I encoded the following:
process(List<String> chunks) {
if (chunks.size() > 0) {
String text = chunks.get(chunks.size() - 1);
label.setText(text);
}
}
The above code works, but my problem (or, more specifically, my doubt) is as follows:
The swing work task above is an anonymous inner class, so it can access the field label.
But what if I want the working swing class to be not an inner class. Do I have to pass the labelswing worker class constructor as an argument so that the process () method can access.
Or is there another way?
swing, swing worker ?