title: JTextArea append performance
body: <p>I want to print text into JTextArea, in order to do that I made simple class that handles that</p>
  
  <pre><code>public class Console {
      private Console() {}
      private static Console instance;
      public static Console console() {
          if(instance == null) instance = new Console();
          return instance;
      }
  
      private JTextArea textArea;
  
      void setTextArea(JTextArea area) {
          textArea = area;
      }
  
      public void write(String message) {
          textArea.append(message+"\n");
          textArea.setCaretPosition(textArea.getDocument().getLength());
          textArea.update(textArea.getGraphics());
      }
  }
  </code></pre>
  
  <p>Now, I start execution of my application and I want to log everything what is happening, for example I use </p>
  
  <pre><code>   public void work(Set&lt;File&gt; files) {
          files.forEach(f -&gt; {
              console().write("Working on " + f.getName());
              doWork(f);
          });
      }
  </code></pre>
  
  <p>Now the problem is - performance of this can be very bad. On lower specs (or laptop running power save mode) whole console blinks with every new line, writing 50~ lines takes few seconds. Whats the cause here? How can I improve that?</p>