title: Multi thread to show java console log in GUI JFrame
body: <p>I got a little problem with Multi-thread </p>
  
  <p>I created a java class <code>InformationConsole</code> to get my java console log, everytime when I use <code>System.out.print("...");</code> The message will send to a JTextArea, it works like a "connection" with java console and my JTextArea</p>
  
  <pre><code>public class InformationConsole extends OutputStream  {
     private JTextArea textArea;
     private final StringBuilder sb = new StringBuilder();
     private String title;
  
     public InformationConsole(final JTextArea textArea, String title) {
        this.textArea = textArea;
        this.title = title;
        sb.append(title + "&gt; ");
     }
  
     @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(title + "&gt; ");
           return;
        }
        sb.append((char) b);
     }
  }
  </code></pre>
  
  <p>And I use it with my GUI to show the log </p>
  
  <pre><code>public class Lancer{
     public static void main(String[] args) {
       SwingUtilities.invokeLater(new Runnable() {
           public void run() {
               CreerEtAffichierGUI();
           }
        });
      }
  
     public static void CreerEtAffichierGUI(){
      JFrame fenetre = new JFrame();
      JTextArea log = new JTextArea();
      InformationConsole consoleInfo = new InformationConsole(log, "InfoConsole");
  
      fenetre.setVisible(true);
      fenetre.setResizable(false);
      fenetre.setLocationRelativeTo(null);
      fenetre.setTitle("Modélisation" );
      fenetre.setBounds(0, 0, 800, 800);
      fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      JButton bouton1 = new JButton("Start" );
      fenetre.setLayout(new GridLayout(2, 1));
       //On ajoute le bouton au content pane de la JFrame
      fenetre.getContentPane().add(bouton1); 
      fenetre.getContentPane(). add(new JScrollPane(log, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER));System.setOut(new PrintStream(consoleInfo));
      bouton1.addActionListener(new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
              CreerModelJCL();
              JOptionPane.showMessageDialog(fenetre, "Modelisation JCL Fini");
          }
      });
      fenetre.setVisible(true);
    }
  }
  </code></pre>
  
  <p>The JTextArea which in GUI don't update in real time, it will show all the log when the application finish, I am a newbee with multi thread, I couldn't find out why...</p>
  
  <p>Could u please give me some help ?</p>
  
  <p>Here is <code>CreerModelJCL()</code> He just have a lot of <code>println</code> with the console </p>
  
  <pre><code>public static void CreerModelJCL(){
  
  System.out.println("--------  Exporter fichier résultat XMI Fini--------------");
  
  System.out.println("------------------------Modelisation JCL    FINI------------------------");
  
  }
  </code></pre>