I would like to create an application wide keyboard shortcut for a Java Swing application. Looping over all components and adding the shortcut on each, has focus related sid
When you have a menu, you can add global keyboard shortcuts to menu items:
JMenuItem item = new JMenuItem(action); KeyStroke key = KeyStroke.getKeyStroke( KeyEvent.VK_R, KeyEvent.CTRL_DOWN_MASK); item.setAccelerator(key); menu.add(item);