Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Setting focus of JTextField

 
Marcus Hoe
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone knows how to set focus on specific JTextComponents such as JTextField... after screen loads ?
 
Renee Zhang
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic