How to move one Text Field to another Text Field by pressing Enter Key?
in Java

Recommended Answers

All 2 Replies

tf2.setText(tf1.getText());

in an ActionListener. If you don't know what an ActionListener is, or how to use one, then read the Swing Tutorials. (addActionListener on a JTextField will cause "Enter" to fire an ActionEvent)

You cannot move one TextField to another. If you want to change focus, use the focusListeners, and/or the keyListeners.
I think there is a method at TextField that sets the focus.
If you want to write to a text Field something from another use the getText(), setText() methods. Also check the API for more details about the syntax

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.