public RegexTextArea() {
    super();
    
    regexListeners = new HashSet<>();
    
    getDocument().addDocumentListener(new DocumentChangeAdapter() {
      public void anyUpdate(DocumentEvent e) {
        try {
          String regexString = StringEscapeUtils.unescapeJava(getText());
          pattern = Pattern.compile(regexString);
        }
        catch(PatternSyntaxException ex) {
          pattern = Pattern.compile("");
        }
        catch(NullPointerException ex) {
          pattern = Pattern.compile("");
        }
        _fireRegexUpdateEvent(new RegexEvent(this, pattern));
      }
    });
  }