• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how can i set the XOR mode of a JTextComponent

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Buddy !
That was really a cool stuff. It solved my problem
Regards
Saurabh
 
reply
    Bookmark Topic Watch Topic
  • New Topic