I have a swing gui with tabbed area in the north. Several key events have been added to the input card:
InputMap paneInputMap = pane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); paneInputMap.put( KeyStroke.getKeyStroke( KeyEvent.VK_E, KeyEvent.CTRL_MASK ), "finish"); paneInputMap.put( KeyStroke.getKeyStroke( KeyEvent.VK_F1, KeyEvent.CTRL_MASK ), "toggletoolbar");
If the tabbed panel or another button on the toolbar has focus, Ctrl + F1 has no function. If another component is focused (for example, JTree), Ctrl + F1 performs the action.
The problem is that it works everywhere if I change Keycode, for example, VK_F2 .
The F1 key is not used anywhere in the program.
Any idea?
Thanks Andre
Edit: A full-text search in the java source code gave the answer: ToolTipManager registers the Ctrl + F1 key to display the tooltip text if a key combination is pressed, therefore, if the tooltip button is focused, Ctrl + F1 is processed by ToolTipManager . Otherwise, my action is called.
source share