java - How to get a JTextField to respond to the enter key -


so want jtexfield put text in jtextarea when enter key pressed cursor in it. can help?

forget using keylistener swing components.

this listener designed use awt components not provide reliable interaction mechanism jtextcomponents.

use actionlistener instead - on vast majority of systems actionevent dispatched jtextfield when enter pressed.

mytextfield.addactionlistener(new actionlistener() {      @override     public void actionperformed(actionevent e) {        mytextarea.append(mytextfield.gettext() + "\n");     } }); 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -