In fact, you want the KeyboardManager to set the KeyEventPostProcessor or even an alternative dispatch for various components. I had the same problems in the NB app like you.
In this article, I used: ( developer.com )
I did this to capture key input events from any control in the panel (to trigger the OK button behavior automatically):
KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); manager.addKeyEventPostProcessor(new EnterKeyListener());
And the listener:
class EnterKeyListener implements KeyEventPostProcessor { @Override public boolean postProcessKeyEvent(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) {
Daver source share