I need to create a class derived from JTextComponent
(from JTextPane
, actually) in which at least one of the default key mappings is changed. That is, in my special JTextPane, I want the ">" keystroke to perform an action and NOT add that character to the text pane as, by default all printable typed characters are treated.
To defeat the normal behavior, there are the following APIs:
JTextComponent.getKeymap()
Keymap.addActionForKeyStroke()
JTextComponent.setKeymap()
However, I find that though these methods are not static they DO affect the keymap used by all JTextComponent
s in my application. There is no simple mechanism by which a Keymap may be cloned which, presumably would solve the problem, or am I missing something.
What I am after is a way to change the keymap for my JTextPane
class but not for ALL JTextComponent
-derived classes.
Or should I be looking elsewhere?