Reputation: 455
The textfield is disabled and with text.
When I touch a button, the textfield will be enabled for editing.
However, I would like to textfield to be cleared when enabled.
One constraint is that I can;t add any other listener to the button.
Is there anyone can answer my question?
Many Thanks!
Upvotes: 0
Views: 274
Reputation: 347204
You could attach a property listener and listen for the "enabled" event
field.addPropertyChangeListener("enabled", listener);
This doesn't require you mess around with the field at all...
Upvotes: 1
Reputation: 461
check here, Here is the answer of your question. You just need some modifications...
Java JTextField with input hint
Upvotes: 0
Reputation: 33534
Try this..
Inside the button listener that enables the textfield, after enabling statement,just add mytext.setText("");
Upvotes: 2