Code: how the curser going down when ever we press enter key
10:36 AM
Kalpa
, Posted in
java
,
0 Comments
I create simple form using netbeance. In this form there have First Name(jLabel1), Last Name(jLabel2), two fields(jTextField1, jTextField2) and two buttons Save(jButton1) Exit(jButton2).
Now if i run the program it display simple form. I add First Name in to the Jtextfield1 and press enter. The curser didn't go to other field. PROBLEM???????
To solve this problem there have code. In this form i want to first add first name and then second name. So first go to the First Name textfield(Jtextfield1). Then Right click >> Events >> Key >> KeyPressed. Then show that methode. So there you have to write some small code.
if (evt.getKeyCode() == 10) {
jTextField2.requestFocusInWindow();
}
10 meance if you press enter. This code saying, if you press enter at Jtextfield1 (==10) curser should go to the Jtextfield2.
It's very simple.. Enjoy with it.
Now if i run the program it display simple form. I add First Name in to the Jtextfield1 and press enter. The curser didn't go to other field. PROBLEM???????
To solve this problem there have code. In this form i want to first add first name and then second name. So first go to the First Name textfield(Jtextfield1). Then Right click >> Events >> Key >> KeyPressed. Then show that methode. So there you have to write some small code.
if (evt.getKeyCode() == 10) {
jTextField2.requestFocusInWindow();
}
10 meance if you press enter. This code saying, if you press enter at Jtextfield1 (==10) curser should go to the Jtextfield2.
It's very simple.. Enjoy with it.
You can leave a response, or trackback from your own site.
0 Response to "Code: how the curser going down when ever we press enter key"
Post a Comment