private static void reregisterGlobalKeys() { // F8 to Ctrl+F8 reregisterGlobalKey("Table.ancestorInputMap", KeyStroke.getKeyStroke(KeyEvent.VK_F8), KeyStroke.getKeyStroke(KeyEvent.VK_F8, KeyEvent.CTRL_DOWN_MASK)); reregisterGlobalKey("SplitPane.ancestorInputMap", KeyStroke.getKeyStroke(KeyEvent.VK_F8), KeyStroke.getKeyStroke(KeyEvent.VK_F8, KeyEvent.CTRL_DOWN_MASK)); } private static void reregisterGlobalKey(String uiManagerKey, KeyStroke oldKeyStroke, KeyStroke newKeyStroke) { Object inputMapObj = UIManager.get(uiManagerKey); if (inputMapObj == null || !(inputMapObj instanceof InputMap)) { System.err.println("reregisterGlobalKey inputMap not found: " + uiManagerKey); return; } InputMap inputMap = (InputMap) inputMapObj; String actionCommand = (String) inputMap.get(oldKeyStroke); if (actionCommand == null) { System.err.println("reregisterGlobalKey actionCommand not found for inputMap: " + uiManagerKey + " keyStroke: " + oldKeyStroke); return; } inputMap.remove(oldKeyStroke); if (newKeyStroke != null) { inputMap.put(newKeyStroke, actionCommand); } }
Keep in mind that these uiManagerKeys and key strokes are Look and Feel dependend.