Exemple #1
0
 // KeyListener interface ---------------
 public void keyPressed(KeyEvent e) {
   int code = e.getKeyCode();
   switch (code) {
     case KeyEvent.VK_DOWN:
       fireActionPerformed("down");
       e.consume();
       break;
     case KeyEvent.VK_UP:
       fireActionPerformed("up");
       e.consume();
       break;
     case KeyEvent.VK_PAGE_DOWN:
       fireActionPerformed("next");
       e.consume();
       break;
     case KeyEvent.VK_PAGE_UP:
       fireActionPerformed("prev");
       e.consume();
       break;
   }
 }
Exemple #2
0
  public void keyTyped(KeyEvent e) {
    char code = e.getKeyChar();
    if (code == e.VK_ENTER) {
      //      if (dataField != null)
      {
        e.setKeyChar(e.CHAR_UNDEFINED);
        e.setKeyCode(-1);

        // only fire this event, if the data has been changed
        if (textField.isDataChanged()) {
          fireActionPerformed("enter");
        }

        // not shift + enter => focus to next
        if ((e.getModifiers() & e.SHIFT_MASK) != e.SHIFT_MASK) {
          this.changeFocusToNext();
        }
      }
    } else {
      if (!TKeyLock.keys.isLocked()) {
        textField.setDataChanged(true);
      }
    }
  }