public void showResult(JEditorPane txt, String result) {
   try {
     if (txt.getText().length() == 0) {
       appendHTML(txt, result);
       txt.setSelectionStart(txt.getText().length());
       txt.setSelectionEnd(txt.getText().length() - 1);
     } else {
       if (txt.getText().length() > MAX_LOG_SIZE) {
         txt.setSelectionStart(0);
         txt.setSelectionStart(txt.getText().length() - MAX_LOG_SIZE);
         txt.replaceSelection("");
       }
       txt.setSelectionStart(txt.getText().length());
       appendHTML(txt, result);
       txt.setSelectionEnd(txt.getText().length());
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
  public void findNext() {
    EditWindow currentWindow = editor.getActiveWindow();

    if (currentWindow == null || getFindTextField().getText().length() == 0) {
      // launch error dialog?
      return;
    }
    Pattern p = getCurrentPattern();
    JEditorPane editorPane = currentWindow.getEditorPane();

    // for some reason, getText() trims off \r but the indexes in
    // the editor pane don't.
    String text = editorPane.getText().replaceAll("\\r", "");
    Matcher m = p.matcher(text);
    int index = editorPane.getSelectionEnd();

    if (!(m.find(index) || m.find())) {
      return;
    }
    editorPane.setSelectionStart(m.start());
    editorPane.setSelectionEnd(m.end());
  }