File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Setting focus of JTextField Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Setting focus of JTextField" Watch "Setting focus of JTextField" New topic

Setting focus of JTextField

Marcus Hoe

Joined: May 18, 2001
Posts: 14
Anyone knows how to set focus on specific JTextComponents such as JTextField... after screen loads ?
Renee Zhang
Ranch Hand

Joined: Sep 10, 2001
Posts: 72
Try yourTextField.requestFocus();
It works for me, but you have to put this line after yourFrame.setVisible(true). I don't know if it's a good idea to put any code after yourFrame.setVisible(true).
Good lucks!
I agree. Here's the link:
subject: Setting focus of JTextField
It's not a secret anymore!