• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can I set the cursor in a particular JTextField?

 
Mike Lipay
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When my application opens I would like to have the cursor already in the first JTextField on the window. Is there a way to do this? The window layout is:



I've looked in the docs under JTextField and Cursor and couldn't find anything relative.
Thanks.
 
Rob Camick
Ranch Hand
Posts: 2536
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


The trick is that the code must be executed "after" the frame is visible.
 
Mike Lipay
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Worked perfectly! Many thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic