tags:

views:

90

answers:

3
Q: 

JTextField

how to set the focus in the JTextField??

+1  A: 

JTextField extends JComponent so JTextField would have this method.

Victor
+2  A: 

The abstract class Component which JTextField extends provides a requestFocus() method.

JTextField jtf = getTextFieldFromSomewhere();
jtf.requestFocus();
Darren Hicks
+3  A: 

Use requestFocusInWindow()

requestFocus() can be used but is discouraged as it is platform dependent.

See here for more details

objects