[英]How to make JTabbedPane not to catch Ctrl+Tab key binding?
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.
因此,对于绑定Ctrl + Tab,我有自己的操作。 It is assigned to JTabbedPane.
它被分配给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.
因此,对于绑定Ctrl + Tab,我有自己的操作。 It is assigned to JTabbedPane.
它被分配给JTabbedPane。
Did you use the proper InputMap when you assigned the Key Binding. 分配键绑定时是否使用了正确的InputMap? Most LAF's will use the
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
InputMap. 大多数LAF将使用
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
InputMap。
See Key Bindings for a list of the bindings for your LAF. 有关您的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: 如果键绑定不起作用,则另一个选择可能是从选项卡式窗格中删除Ctrl-Tab作为焦点遍历键:
Set newForwardKeys = new HashSet();
newForwardKeys.add( KeyStroke.getKeyStroke("TAB") );
tabbedPane.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, newForwardKeys);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.