This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Setting focus of JTextField" Watch "Setting focus of JTextField" New topic
Author

Setting focus of JTextField

Marcus Hoe
Greenhorn

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!
 
Consider Paul's rocket mass heater.
 
subject: Setting focus of JTextField
 
Similar Threads
java swings question
Doubts-Urgent!
RequestFocus doesn't work?
Retaining Focus in Swing
focusLost event