SwingWorker problem!!! How can I run it 2 times or more?
Hello!!
I am new in Java. I use the following code:
SwingWorker SWorker = new SwingWorker<String, Void>()
{
public String doInBackground() {
return CargarInformacion();
}
public void done() {
try {
JTextAreaReport.append(get());
} catch(InterruptedException ie){
System.out.println(ie.toString());
} catch(java.util.concurrent.ExecutionException ee){
System.out.println(ee.toString());
}
}
};
private String CargarInformacion()
{
try {
in = new BufferedReader(new FileReader(file));
<read file...>
}
return StrMessage;
}
The problem is that when this code runs for the first time it works perfect!!! but I need to use it several times with other file names. In the java docs I found the following text:
"SwingWorker is only designed to be executed once. Executing a SwingWorker more than once will not result in invoking the doInBackground method twice."
How can I resolve this?
thank's.
David.