• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

textField clearing and System.exit().

 
ken zemaitis
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone. I was wondering if anyone knew of a way to clear a textField when someone clicks in it to enter data. I have a message that displays "Enter ID Here..." that I would like to have disappear when the user clicks in the box to enter their own data. I also coded a button(not a jbutton) into my program to have the program exit, and I was unsuccessful in coding it correctly. Any help on either question would be appreciated. Thanks a lot.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your TextField needs a FocusListener; in the FocusListener implementation, you can look at the TextField's text and decide to change it (or not.)

Your button just needs to call System.exit() in an ActionListener; i.e.,


 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Be aware, though, that applets are not allowed to call System.exit().
 
ken zemaitis
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulf Dittmer:
Be aware, though, that applets are not allowed to call System.exit().


Haha yeah, that is something I figured out after about a half hour. Thanks.
 
ken zemaitis
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ernest Friedman-Hill:
Your TextField needs a FocusListener; in the FocusListener implementation, you can look at the TextField's text and decide to change it (or not.)

Your button just needs to call System.exit() in an ActionListener; i.e.,




Thank you very much.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic