Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

need JTextField that change color when focused  RSS feed

 
Francesco Pezzino
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to implement a JTextField that turn its background yellow when has focus and turn back white when there is any focus.
Please can someone give me some suggestions ? thanks in advance
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I suggest using FocusListener. Change background to yellow in focusGained method and change background to white in focusLost method.
Regards,
Manfred.
 
Francesco Pezzino
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Manfred for the suggestion, I think it's a smart way to solve this problem, I'll implement this way.
Francesco
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!