public void find(boolean wrap) {
    // in case search len is zero,
    // otherwise replace all will go into an infinite loop
    found = false;

    String search = findField.getText();
    //System.out.println("finding for " + search + " " + findString);
    // this will catch "find next" being called when no search yet
    if (search.length() == 0) return;

    String text = editor.getText();

    if (ignoreCase) {
    search = search.toLowerCase();
      text = text.toLowerCase();
    }

    //int selectionStart = editor.textarea.getSelectionStart();
    int selectionEnd = editor.getSelectionStop();

    int nextIndex = text.indexOf(search, selectionEnd);
    if (nextIndex == -1) {
      if (wrap) {
        // if wrapping, a second chance is ok, start from beginning
        nextIndex = text.indexOf(search, 0);
      }

      if (nextIndex == -1) {
        found = false;
        replaceButton.setEnabled(false);
        replaceFindButton.setEnabled(false);
        //Toolkit.getDefaultToolkit().beep();
        return;
      }
    }
    found = true;
    replaceButton.setEnabled(true);
    replaceFindButton.setEnabled(true);
    editor.setSelection(nextIndex, nextIndex + search.length());
  }