title: System.out.println to JTextArea
body: <p><strong>EDIT:</strong> I have edited the post to clarify my question, now I myself, have more understanding.</p>
  
  <p>I am essentially, as the title says, attempting to output console to my <code>JTextArea</code> in my GUI, whilst performing the tasks of the application.</p>
  
  <p>Here is what I am currently doing:</p>
  
  <pre><code>public class TextAreaOutputStream extends OutputStream
  {
  
      private final JTextArea textArea;
  
      private final StringBuilder sb = new StringBuilder();
  
      public TextAreaOutputStream(final JTextArea textArea)
      {
          this.textArea = textArea;
      }
  
      @Override
      public void flush()
      {
      }
  
      @Override
      public void close()
      {
      }
  
      @Override
      public void write(int b) throws IOException
      {
  
          if (b == '\r')
              return;
  
          if (b == '\n')
          {
              final String text = sb.toString() + "\n";
              SwingUtilities.invokeLater(new Runnable()
              {
                  public void run()
                  {
                      textArea.append(text);
                  }
              });
              sb.setLength(0);
          }
          sb.append((char) b);
      }
  }
  </code></pre>
  
  <p>The above will successfully re-direct <code>System.out</code> to my output stream above and therefore despatch an event to the <code>EventQueue</code> to update my GUI (<code>JTextArea</code>).</p>
  
  <p>Here is the issue:</p>
  
  <p>Currently using <code>invokeLater()</code> will as it says on the docs:</p>
  
  <p><code>Causes runnable to have its run method called in the dispatch thread of the EventQueue. This will happen after all pending events are processed.</code></p>
  
  <p>So what I actually want to do is perform my update to the GUI (call <code>run()</code>) before processing everything else in the EventQueue.</p>
  
  <p>Is it possible to inject an event essentially into my EventQueue? Or can somebody point me to an decent tutorial on this area?</p>
  
  <p>thanks,</p>