public void mousePressed(MouseEvent evt)
    {
      requestFocus();

      // Focus events not fired sometimes?
      setCaretVisible(true);
      focusedComponent = JEditTextArea.this;

      // isPopupTrigger wasn't working for danh on windows
      boolean trigger = (evt.getModifiers() & InputEvent.BUTTON3_MASK) != 0;
      // but it's required for macosx, since control-click does
      // the same thing as a right-mouse click
      if (!trigger && evt.isPopupTrigger()) trigger = true;

      if (trigger && (popup != null)) {
        popup.show(painter,evt.getX(),evt.getY());
        return;
      }

      int line = yToLine(evt.getY());
      int offset = xToOffset(line,evt.getX());
      int dot = getLineStartOffset(line) + offset;

      switch(evt.getClickCount()) {

      case 1:
        doSingleClick(evt,line,offset,dot);
        break;

      case 2:
        // It uses the bracket matching stuff, so
        // it can throw a BLE
        try {
          doDoubleClick(evt,line,offset,dot);
        } catch(BadLocationException bl) {
          bl.printStackTrace();
        }
        break;

      case 3:
        doTripleClick(evt,line,offset,dot);
        break;
      }
    }