Two Laptop Bag
The moose likes Swing / AWT / SWT and the fly likes JTextField question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTextField question" Watch "JTextField question" New topic

JTextField question

john mattucci
Ranch Hand

Joined: Nov 03, 2000
Posts: 331
Is there any way to make an entry disappear once a user presses
enter. Eg John is typed into a textfield and once the user presses enter the textfield is once again blank
Thank you for your help.
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

yup, there is.
When the enter (return) key is pressed in the TextField, an action event is generated and
you could add an action listner which will set the TextField
to " ".
One way of doing it.
- satya

Take a Minute, Donate an Hour, Change a Life
It is sorta covered in the JavaRanch Style Guide.
subject: JTextField question