简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM