I'm trying to make a multi-line JTextField using JTextArea an an action map with Java.
Here's the important part of the code:
Code:
input.getInputMap().put(KeyStroke.getKeyStroke("ENTER"),"submit_data");
InputMap im = input.getInputMap(JComponent.WHEN_FOCUSED);
im.put(KeyStroke.getKeyStroke("ENTER"), "submit_data");
ActionMap am = new JTextArea().getActionMap();
am.put("submit_data",
new AbstractAction("submit_data") {
public void actionPerformed(ActionEvent evt) {
System.out.println("Someone hit enter");
}
}
);
I can tell that something is working because "ENTER" no longer creates a new line. However, it never prints "Someone hit enter." What's wrong?
Also, please excuse my typo in the title. It appears that there is no way to fix it.