Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ENTER key using in JTextField java

I'm using two JTextField in Java Swing form. Now I enter the values in JTextField1. Next if I press ENTER KEY means the cursor move to JTextField2. How to do this?

like image 1000
java872 Avatar asked Dec 16 '22 06:12

java872


1 Answers

Add an ActionListener to the first text field. In the ActionEvent you can get the source object, cast it to a JTextField and then invoke the transferFocus() method.

like image 135
camickr Avatar answered Dec 27 '22 14:12

camickr