title: JTextArea Document Listener updating text
body: <p>I have a JTextArea and I'd like to listen when the user pastes text in the JtextArea. Specifically, I'd like to do the following:</p>
  
  <p>Get the text they pasted, remove whitespaces, and replace the JTextArea text with the edited text without spaces (rather than the original text the user pasted).</p>
  
  <p>How can I do this using a DocumentListener, and avoiding <code>java.lang.UnsupportedOperationException: Not supported yet.</code>, which comes as a result of the following code:</p>
  
  <pre><code>public void insertUpdate(DocumentEvent de) {
  
          final String replace = jTextArea1.getText().replaceAll("\\s","");
  
          SwingUtilities.invokeLater(new Runnable() {
              public void run() {
              jTextArea1.setText(replace);
              }
           });
  
      }
  </code></pre>