Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a Swing element which has F6 as a default accelerator?

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?

like image 449
Neifen Avatar asked Nov 23 '11 14:11

Neifen


People also ask

When KeyEvent is generated?

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.


1 Answers

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");
like image 117
Walter Laan Avatar answered Oct 04 '22 19:10

Walter Laan