Question : SwingWorker setProgress problem

In the code below, I would like to increment the progress bar from within doSomeStuff().
I've tried passing the Task into it, as Task and as SwingWorker, but this doesn't work because it says that setProgress() is not visible.
How do I do this?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
public class MyClass {

private JProgressBar progressBar;

<init stuff>

class Task extends SwingWorker<Void, Void> {


    // Main task. Executed in background thread.
    @Override
    public Void doInBackground() {

	setProgress(10);

        doSomeStuff();

Answer : SwingWorker setProgress problem

You should be calling SwingWorker.publish, not setProgress, and any GUI stuff should, as a result of that call to publish, be treated in SwingWorker.process
Random Solutions  
 
programming4us programming4us