GeeCON Prague 2014*
The moose likes Swing / AWT / SWT and the fly likes Can I set the cursor in a particular 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 "Can I set the cursor in a particular JTextField?" Watch "Can I set the cursor in a particular JTextField?" New topic
Author

Can I set the cursor in a particular JTextField?

Mike Lipay
Ranch Hand

Joined: Sep 11, 2007
Posts: 171
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

Joined: Jun 13, 2009
Posts: 2191
    
    7


The trick is that the code must be executed "after" the frame is visible.
Mike Lipay
Ranch Hand

Joined: Sep 11, 2007
Posts: 171
Worked perfectly! Many thanks.
 
GeeCON Prague 2014
 
subject: Can I set the cursor in a particular JTextField?