title: JTextArea and DocumentFilter
body: <p>I am using a jtextarea and a document filter. I want as soon as the user presses "b" in it, the whole text to be deleted, except, let's say the first letter. How can I accomplish this. Some ideas would be useful.</p>
  
  <pre><code>public void replace(FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException {
          if ("b".equalsIgnoreCase(text)) {
              //what here???
          }
          super.replace(fb, offset, length, text, attrs); 
      }
  </code></pre>
  
  <p>Thanks a lot</p>