This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes SETTING FOCUS ON A TEXT FIELD Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "SETTING FOCUS ON A TEXT FIELD" Watch "SETTING FOCUS ON A TEXT FIELD" New topic
Author

SETTING FOCUS ON A TEXT FIELD

RAY CARNES
Greenhorn

Joined: May 02, 2000
Posts: 11
I want to put the pointer (or hatever it's called in a text field) onto the text field so the user can just start typing. I haven't been able to find the method to do this.
Todd M Bush
Greenhorn

Joined: Apr 26, 2000
Posts: 22
To give a component the default focus when the window first opens, you must use the component.requestFocus() command in the window opened event. Like this....
frame.addWindowListener(new WindowAdapter() {
public void windowOpened(WindowEvent we) {
textfield.requestFocus();
}
});
hope this helps
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: SETTING FOCUS ON A TEXT FIELD