I made a login dialog with JTextField and JPasswordField. However, right now when the popup shows that the "OK" button is highlighted. I want it to start on the username input box as soon as the popup shows. I've looked at many different methods but none of them seem to work. How might I do this?
Asked
Active
Viewed 62 times
0
-
See http://stackoverflow.com/questions/6723257/how-to-set-focus-on-jtextfield – panoptical Nov 09 '13 at 05:53
-
2By default the first focusable component on the dialog will have focus. I'm sure you don't define the "Ok" button first so you must be doing something strange. Post your [SSCCE](http://sscce.org/) that demonstrates the problem. – camickr Nov 09 '13 at 05:55
1 Answers
1
One solution is to call requestFocusInWindow()
on the JTextField. If you've tried this and it doesn't work, then you'd best show us how you've tried this.

Hovercraft Full Of Eels
- 283,665
- 25
- 256
- 373