0

I want to get all the stream that I output using System.out.println(...) in the JTextArea and the code below does that absolutely fine however, I have lots of those printlns but the way they are printed in my console is a 'one-off' process. I mean they are being printed right at the end of running my program and not 'sequentially' so I could actually see it like in the real console log. I output some data about documents I scan, keywords found in a document etc so there's lots of code.

PrintStream out = new PrintStream( new TextAreaOutputStream( consoleTextArea ) );
System.setOut( out );
System.setErr( out );

I want to be able to only print those console lines in the consoleTextArea but not all in one go. This make a user feel that the program has frozen and no output is being displayed.

  • 1
    You've got threading issues. Use a SwingWorker to help you avoid blocking the Swing event thread. – Hovercraft Full Of Eels Feb 06 '18 at 12:22
  • Not sure how to apply this in my case. What shall I put in the doInBackground method and should it be in GUI class or the documentSearch class? – dsafas fsafasfsa Feb 06 '18 at 14:31
  • It is very difficult for us to know what you should do as you've not posted nearly enough code to allow us to understand your exact problem or its solution. We don't want to see all your code but we do want to see "enough". Please read the [SSCCE](http://sscce.org) to see what this entails. Also look at the [mcve] link as well. – Hovercraft Full Of Eels Feb 06 '18 at 17:33

0 Answers0