aspose file tools
The moose likes Swing / AWT / SWT / JFace and the fly likes Changing the color of Selected Text Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT / JFace
Reply Bookmark "Changing the color of Selected Text" Watch "Changing the color of Selected Text" New topic
Author

Changing the color of Selected Text

Syed Usman
Greenhorn

Joined: Dec 10, 2001
Posts: 6
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


Spacefiller
Michael Szul
Ranch Hand

Joined: Sep 18, 2001
Posts: 57
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

Joined: Aug 14, 2001
Posts: 342
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.


SCJP 1.4, www.gsi3d.org.uk
 
 
subject: Changing the color of Selected Text
 
Threads others viewed
Partial selection of Text in textArea
Yahoo E-mail
Writing Email Messages Using Yahoo Account
How to make JComboBox flash (red color)?
How to set the fontcolor and size for the selected text of text area ?
MyEclipse, The Clear Choice