I need an example how to add a keyboard handler that detect when Ctrl+C , Ctrl+X , Ctrl+C pressed on a JTree.
JTree
I were do this before with menu shortcut keys but with no success.
You can add KeyListeners to any component (f)
f.addKeyListener(new KeyListener() { @Override public void keyTyped(KeyEvent e) { } @Override public void keyPressed(KeyEvent e) { if ((e.getKeyCode() == KeyEvent.VK_C) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) { System.out.println("woot!"); } } @Override public void keyReleased(KeyEvent e) { } });
1.4m articles
1.4m replys
5 comments
57.0k users