Java JTabed窗格正在读取击键和切换选项卡

Java JTabed窗格正在读取击键和切换选项卡,java,swing,keylistener,jtabbedpane,incompatibility,Java,Swing,Keylistener,Jtabbedpane,Incompatibility,我使用的是按键侦听器和jtabbed窗格,每当我尝试使用键盘上的左键和右键时,它只是在选项卡之间切换。这真的很烦人,因为我实际上正在使用其中一个选项卡中的箭头键。有没有办法在java中关闭“开关选项卡”按键功能 先谢谢你 KeyListen keylistener = new KeyListen(); MainGUI.MainTabbedPane.addKeyListener(keylistener); MainGUI.MainTabbedPane.getInputMap(JCo

我使用的是按键侦听器和jtabbed窗格,每当我尝试使用键盘上的左键和右键时,它只是在选项卡之间切换。这真的很烦人,因为我实际上正在使用其中一个选项卡中的箭头键。有没有办法在java中关闭“开关选项卡”按键功能

先谢谢你

KeyListen keylistener = new KeyListen();
    MainGUI.MainTabbedPane.addKeyListener(keylistener);
    MainGUI.MainTabbedPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("LEFT"), "none");
    MainGUI.MainTabbedPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("RIGHT"), "none");

是的,你必须注销keybinding,你可以这样做

tabComponent.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("LEFT"), "none");
tabComponent.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("RIGHT"), "none");

你可能想看看这个。不建议使用KeyListeners而使用keybinding,因为首先必须有焦点,而且KeyListeners适用于所有键,keybinding适用于特定键

所以我的程序还是不起作用这里是我的代码。我想知道你是否能给我一些更深入的了解,为什么它可能不起作用。(原始邮政中的邮政编码)@nachokk@nachokk:+1用于更新;也可以考虑引用相关的教程章节。你根本不应该使用密钥侦听器(它在做什么?),而是使用自定义键绑定。