如何使JTabbedPane不捕获Ctrl + Tab键绑定? [英] How to make JTabbedPane not to catch Ctrl+Tab key binding?
问题描述
当我按下Ctrl
+ Tab
时,JTabbedPane
中选定的选项卡将获得焦点.
When I press Ctrl
+Tab
, selected tab in JTabbedPane
receives focus.
但是我想删除此键绑定.因此,对于绑定Ctrl + Tab,我有自己的操作. 它已分配给JTabbedPane.
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.
推荐答案
因此,对于绑定Ctrl + Tab,我有自己的操作.它已分配给JTabbedPane.
So I have my own action for key binding Ctrl+Tab. It is assigned to JTabbedPane.
分配键绑定时是否使用了正确的InputMap.大多数LAF将使用JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
InputMap.
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.
有关您的绑定列表,请参见键绑定. LAF.
See Key Bindings for a list of the bindings for your LAF.
如果键绑定不起作用,则另一个选择可能是从选项卡式窗格中删除Ctrl-Tab作为焦点遍历键:
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);
这篇关于如何使JTabbedPane不捕获Ctrl + Tab键绑定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!