protected void processKeyEvent(final KeyEvent e) { int id = e.getID(); switch (id) { case KeyEvent.KEY_TYPED: KeyEventCZ loKey = new KeyEventCZ(e.getKeyChar()); moTipo.getTecla(super.getText(), loKey); e.setKeyChar(loKey.getKeyChar()); break; case KeyEvent.KEY_PRESSED: if (e.getKeyCode() == e.VK_ENTER) { e.setKeyCode(0); transferFocus(); } if (e.getKeyCode() == e.VK_ESCAPE) { e.setKeyCode(0); moTipo.restaurarTexto(); super.setText(moTipo.getText()); } break; case KeyEvent.KEY_RELEASED: break; default: } super.processKeyEvent(e); }
@Override public void keyPressed(KeyEvent keyEvent) { super.keyPressed(keyEvent); switch (keyEvent.getKeyCode()) { case KeyEvent.VK_PAGE_DOWN: keyEvent.setKeyCode(0); // discontinue, key is been handled goToNextScene(); break; case KeyEvent.VK_PAGE_UP: keyEvent.setKeyCode(0); // discontinue, key is been handled goToPreviousScene(); break; default: break; } }
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); } } }