Here is my sample code... I am facing problem that my swingWorker extended class is only showing doInBackground() to me as overided method. I want to use done() and process() methods also but my class is not showing it @overided nor calling done/process method where it is required to call leave the while loop stuff etc. because I know it is infinite loop but why not the process method is called upon publish()?
public class getChatSwingWorkerThread extends SwingWorker<String , String> {
private final JTextArea chat_text_area;
private PostDataConnection post = null;
private BasicUserInterface chatWindow = null;
public getChatSwingWorkerThread(JTextArea text_area){
chatWindow = new BasicUserInterface();
this.chat_text_area = text_area;
post = new PostDataConnection();
}
@Override
protected String doInBackground() throws Exception {
String returnData = "";
while(true){
returnData = post.getAvailableChat();
if(!returnData.equals("")){
publish(returnData);
}
}
}
protected void process(String returnData) {
chat_text_area.append(returnData);
}
public void done(String returnData) throws InterruptedException, ExecutionException{
chat_text_area.append(get());
}
That is because your process
and done
method have a different signature then the one in the super class.
The signature for the process
method is
protected void process(List<V> chunks)
which in your case comes down to
protected void process(List<String> chunks)
The done
method does not have any parameters
protected void done()