If I'm not mistaken, you should be able to call the super method you are overloading after all of your custom actions.
How to handle a keystroke event in java, but pass it on so that it has it's "natural" effect?
質問
I have this code that makes some action execute when user is in textArea (JTextArea instance) and 'enter' is pressed:
textArea.getInputMap().put(
KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), actionMapKey);
textArea.getActionMap().put(actionMapKey, new AbstractAction() {
int numLines, lineStart, lineEnd;
Element lineElem;
String lineText;
@Override
public void actionPerformed(ActionEvent e) {
//all the things to be done when enter is pressed
}
});
It works fine, but after the action is handled, no newline appears in the textArea. Is there any way to pass the 'enter' keystroke on so that it actually creates newline?
Thanks
解決
所属していません StackOverflow