Button click blocks GUI - optimization needed
I have a Swing GUI where I redirect thestdin andstderr to aJTextArea by the following
JTextArea textarea_output =new JTextArea(2,20);
PrintStream ps =new PrintStream(new FilteredStream(new ByteArrayOutputStream()));
System.setOut(ps);
System.setErr(ps);
// and an inner class which outputs information within the JTextArea
class FilteredStreamextends FilterOutputStream{
public FilteredStream(OutputStream aStream){
super(aStream);
}
publicvoid write(byte b[])throws IOException{
String s =new String(b);
textarea_output.append(s);
}
Upon a JButton click on the GUI I call within theactionPerformed method an external Java class that does a lot of processing and produces lots of output.
The problem is that the button click blocks everything until the called external Java class finished its processing. The real trouble is that the user has to wait a long time before anything happens and even a single line of output is displayed in theJTextArea...
Any ideas/ suggestions how to optimize/ redesign this in order to get a prompt response, please?

