Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Focussing a TextField

 
Help Me
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I've written an AWT Frame with text fields and buttons. On pressing the "Clear" button, I want the text fields to be cleared and the cursor should return to the first text field. I've done clearing the text fields. But how do I return the cursor to the first text field?

Here is my code so far:

Thanks & Regards,
Babu Rajendran
[ February 18, 2007: Message edited by: Babu Rajendran ]
 
Campbell Ritchie
Sheriff
Posts: 48645
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Morning . . .

Please use the "code" button before sumbitting code; it makes it easier to read.

I tried it and as you say the fields cleared.
Not sure about the cursor going back to field 1, but try requesting the focus to the TextField. Go through the TextField API and you should find a suitable method, requestFocus().

CR
 
Help Me
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Campbell,

Thanks a lot! As you've mentioned, I found the requestFocus() method in the Component class. I'm now able to bring the cursor back to the textfield.

Thanks,
Babu
 
Campbell Ritchie
Sheriff
Posts: 48645
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only too pleased to help . . .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic