permaculture playing cards*
The moose likes Swing / AWT / SWT and the fly likes Getting focus on first field on Form load Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Getting focus on first field on Form load" Watch "Getting focus on first field on Form load" New topic
Author

Getting focus on first field on Form load

bhuwan tiwari
Greenhorn

Joined: Jan 04, 2001
Posts: 19
Hi,
As usual i wish to set my focus to first field of the form.
But by default it goes to the last component added.
i tried the method:
requestDefaultFocus()
requestFocus()
grabFocus()
but none of them is working when first time form is created.
plz suggest the way.
bhuwan
Helmut Lerch
Ranch Hand

Joined: Feb 11, 2001
Posts: 48
Hy,
Originally posted by bhuwan tiwari:
i tried the method:
requestDefaultFocus()
requestFocus()
grabFocus()
but none of them is working when first time form is created.

as far as I know you have to call this method after the container is visible.


[This message has been edited by Helmut Lerch (edited July 09, 2001).]
Harry Pfohl
Greenhorn

Joined: Apr 21, 2001
Posts: 17
Hi,
get first component of the panel and call seFocus(true) on it.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Getting focus on first field on Form load
 
Similar Threads
Want to set focus on a Field
Struts error, focus the error field
Cant able to get focus at perticular textfield in javascript
Validator in Struts
js event help