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

Changing the color of Selected Text  RSS feed

 
Syed Usman
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello I am using Swings and developing an editor.
I am getting a problem that I want to change the color of my Selected Text, either I use Swings JEditorKit or TextArea. The problem is only how to do this..
Can you solve this problem..
Thanks...
Syed Usman
------------------
Spacefiller
 
Michael Szul
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're talking about changing the color of the selector itself (i.e. the selected area), you would probably want to use the UIManager. This is dealt with in Look and Feel.
If you just want to change the text color after it's select, you should check out some of the tutorials on styles and JTextPane (I believe's it's JTextPane).
The SDK demo comes with an editor showing the use of styles. You might want to check it out.
 
Ben Wood
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I'm correct about what you're trying to do , it shoudl simply be:
setSelectedTextColor(Color c)
so, something like...
mytextcomponent.setSelectedTextColor(Color.red);
will do it.
hope this helps,
Ben.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!