• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ho could I erase the text field contents as soon as the user presses the CTRL key

 
kei hosima
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.
I hope someone could help me.
How could I erase a text field's contents as soon as the user presses the CTRL key while the text field has focus?
"data" is a properly instantiated TextField object with class-wide scope and the current object as its registered KeyListener.
public void keyTyped (KeyEvent e) {
TextField t = data.getText();
t.clearRect (0, 0, data.getWidth(), data.getHeight());
}
the above code won't work.
I would really appreciate your help.
Thanks in advance.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi kei,
Try something like this:


Michael Morris
 
kei hosima
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael
Thank you so much for your help.
I'll try your code.
thank you!
kei
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic