Volodymyr Levytskyi
Volodymyr Levytskyi

Reputation: 3432

How to make JTabbedPane not to catch Ctrl+Tab key binding?

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.

Upvotes: 1

Views: 523

Answers (1)

camickr
camickr

Reputation: 324207

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);

Upvotes: 2

Related Questions