Question

When I press Ctrl+Tab, selected tab in JTabbedPane receives focus.

But I want to remove this key binding. So I have my own action for key binding Ctrl+Tab. It is assigned to JTabbedPane.

But it's not fired because this key binding still focuses current tab.

Was it helpful?

Solution

So I have my own action for key binding Ctrl+Tab. It is assigned to JTabbedPane.

Did you use the proper InputMap when you assigned the Key Binding. Most LAF's will use the JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT InputMap.

See Key Bindings for a list of the bindings for your LAF.

If the Key Binding don't work then another option might be to remove Ctrl-Tab as a focus traversal key from your tabbed pane:

Set newForwardKeys = new HashSet();
newForwardKeys.add( KeyStroke.getKeyStroke("TAB") );
tabbedPane.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, newForwardKeys);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top