I have an application with a tabbed pane and different components in it. I have set a MenuItem as Action with an Accelerator:
private final Action focusDefaultCommandsAction = new AbstractAction()
{
{
putValue(NAME, "Fokusiere Kommandoliste");
putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0));
}
@Override
public void actionPerformed(final ActionEvent e)
{
invokeShowCommandsList();
}
};
I know there is one tab where the Accelearator for the F6 key doesn't work. the F7 key works.
Is there maybe a default accelerator on a Swing Element that has priority over my accelerator?
This low-level event is generated by a component object (such as a text field) when a key is pressed, released, or typed. The event is passed to every KeyListener or KeyAdapter object which registered to receive such events using the component's addKeyListener method.
You can look this up in BasicLookAndFeel.java (or similar class depending on the L&F you use), search on F6.
Looks like F6 is used by JSplitPane to toggle focus between the content and the dividers. To remove it you could use something like (not tested, I think removing the actual action is harder because it might be in a parent input map):
splitPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
.put(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0), "none");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With