Results 1 to 4 of 4
- 10-02-2008, 04:53 AM #1
Member
- Join Date
- Oct 2008
- Posts
- 2
- Rep Power
- 0
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.
-
First off, I recommend against cross-post questions in multiple forums as this will frustrate anyone who tries to help you only to find out later that the same answer was given hours ago in a cross-posted thread. For this reason, many volunteers here and at the other sites refuse to help repeat offenders.
Next, it's even worse to do this and not respond to any responses in the other posts. This will not encourage folks to help you further you know if they just assume that you will ignore them.
If you respond to your posts (and let's keep this in the original post in the Sun Swing forum), someone will help you, guaranteed. Up to you.Last edited by Fubarable; 10-02-2008 at 05:09 AM.
- 10-02-2008, 05:30 AM #3
Member
- Join Date
- Oct 2008
- Posts
- 2
- Rep Power
- 0
ok, I will follow on the original post:
thank you.
-
Similar Threads
-
Recursive Method ==> find how many times a value is repeated in an array
By NatNat in forum New To JavaReplies: 2Last Post: 02-16-2008, 08:52 PM -
presse 1 menuitem execute 4 times the same JFrame
By marcvb in forum New To JavaReplies: 0Last Post: 12-27-2007, 09:48 PM -
Problem calling classes to flip coin x number of times and record heads or tails
By adlb1300 in forum New To JavaReplies: 2Last Post: 11-11-2007, 08:07 AM -
swingworker
By musiigedeo in forum AWT / SwingReplies: 1Last Post: 07-26-2007, 12:59 PM


LinkBack URL
About LinkBacks

Bookmarks