• Post Reply Bookmark Topic Watch Topic
  • New Topic

how can i set the XOR mode of a JTextComponent

 
Jain Saurabh
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi !
How can i set the XOR mode of a JTextComponent. I want to set the color of the text of a JTextField, which has some color, to it's opposite and also i want to show the text as selected.
Thanks
Saurabh
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't set XOR mode on the text component... but you could probably do something like...



That would make the foreground color the exact opposite of what it was...

or... you could do something like :


which would swap foreground and background colors...

Just call this code from both the methods of FocusListener, and add the FocusListener to the component you want... then whenever it is selected it will show opposite colors...
 
Jain Saurabh
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Buddy !
That was really a cool stuff. It solved my problem
Regards
Saurabh
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!