Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • 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: 2703
10
  • 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.
 
I am mighty! And this is a mighty small ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!