java - switching JTextFields by pressing Enter key -
i have created number of text fields , i'm wonder how can switch focus between fields pressing come in key.
in addition, can command target field ? illustration can defined pressing enter
in field a
focus alter field c
?
simple example:
suppose have 2 jtextfield
s: textfield
, textfield1
textfield.addactionlistener(new actionlistener() { @override public void actionperformed(actionevent e) { textfield1.requestfocusinwindow(); } }); textfield1.addactionlistener(new actionlistener() { @override public void actionperformed(actionevent e) { textfield.requestfocusinwindow(); } });
now when nail enter
when focused on first jtextfield
, other 1 focused, , vice versa.
java swing focus jtextfield
No comments:
Post a Comment