我发现在我的JTextPane中使用Ctrl+Shift+O会改变组件的方向。
对于我的文本编辑器,我需要禁用这个快捷键,但是JTextPane或其他Swing组件中是否有其他快捷键呢?
已知键盘绑定Ctrl-X、Ctrl-C和Ctrl-V,还有更多吗?
对于我的文本编辑器,我需要禁用这个快捷键,但是JTextPane或其他Swing组件中是否有其他快捷键呢?
已知键盘绑定Ctrl-X、Ctrl-C和Ctrl-V,还有更多吗?
但是JTextPane或其他Swing组件中是否有其他快捷方式?
请参见键绑定,其中列出了所有绑定并显示如何禁用不需要的绑定。
myTextPane.getKeymap().removeKeyStrokeBinding(
KeyStroke.getKeyStroke("ctrl shift O"));
这将从myTextPane
中移除该加速器的绑定。
如果您想查找所有键绑定,只需遍历Keymap
:
for (KeyStroke stroke: myTextPane.getKeymap().getBoundKeyStrokes())
{
Sytem.out.println(stroke.toString());
}
KeyStroke
:JTextComponent.getKeymap(JTextComponent.DEFAULT_KEYMAP).removeKeyStrokeBinding(
KeyStroke.getKeyStroke("ctrl shift O"));
JTextComponent.DEFAULT_KEYMAP
定义了默认情况下每个JTextComponent
(包括子类如JTextPane
)都使用的公共Keymap
的名称。
Ctrl
键。 - oliholz