Пример #1
0
 private void checkCompletion(java.awt.event.KeyEvent ke) throws BadLocationException {
   Document doc = getDocument();
   Element root = doc.getDefaultRootElement();
   int pos = getCaretPosition();
   int lineIdx = root.getElementIndex(pos);
   Element line = root.getElement(lineIdx);
   int start = line.getStartOffset(), len = line.getEndOffset() - start;
   String strLine = doc.getText(start, len - 1);
   Debug.log(9, "[" + strLine + "]");
   if (strLine.endsWith("find") && ke.getKeyChar() == '(') {
     ke.consume();
     doc.insertString(pos, "(", null);
     ButtonCapture btnCapture = new ButtonCapture(this, line);
     insertComponent(btnCapture);
     doc.insertString(pos + 2, ")", null);
   }
 }
  /** EdiDialog constructor comment. */
  public void keyReleased(java.awt.event.KeyEvent e) {
    if (e.getSource() == list) {
      switch (e.getKeyCode()) {
        case KeyEvent.VK_DELETE:
        case KeyEvent.VK_BACK_SPACE:
          if (keys.length() > 0) keys.setLength(keys.length() - 1);
          break;
        case KeyEvent.VK_ESCAPE:
          dispose();
          break;
        case KeyEvent.VK_ENTER:
          dispose();
          actionOK();
          break;
        case KeyEvent.VK_SPACE:
          actionAdd();
          break;
        default:
          // keys.append((char) e.getKeyChar());
          list.ensureIndexIsVisible(list.getSelectedIndex());
      }

      //		if (debug)
      //			System.out.println("keys: " + keys);
      return;
    }

    switch (e.getKeyCode()) {
      case KeyEvent.VK_ENTER:
      case KeyEvent.VK_ESCAPE:
        dispose();
        break;
      default:
        break;
    }

    super.keyReleased(e);
  }