开发者

What are the hidden Shortcuts in Swing Components?

I found out Ctrl+Shift+O in my JTextPane changes the ComponentOrientation.

For my own TextEditor I have to disable this, but are there other Shortcuts in JTextPane or in 开发者_如何学编程other Swing-Components?

Keyboard bindings Ctrl-X, Ctrl-C, and Ctrl-V are known.

Are there more?


but are there other Shortcuts in JTextPane or in other Swing-Components?

See Key Bindings which lists all the bindings and shows how to disable a binding you don't want.


Try the following (I haven't checked it myself):

myTextPane.getKeymap().removeKeyStrokeBinding(
    KeyStroke.getKeyStroke("ctrl shift O"));

That should remove the binding from that accelerator for myTextPane.

If you want to find all key bindings then just iterate through the Keymap:

for (KeyStroke stroke: myTextPane.getKeymap().getBoundKeyStrokes())
{
    Sytem.out.println(stroke.toString());
}

Note that you can also disable a given KeyStroke for all text components:

JTextComponent.getKeymap(JTextComponent.DEFAULT_KEYMAP).removeKeyStrokeBinding(
    KeyStroke.getKeyStroke("ctrl shift O"));

Because JTextComponent.DEFAULT_KEYMAP defines the name of the common Keymap used by default for every JTextComponent (including subclasses like JTextPane).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜