aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Change text color.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Change text color.." Watch "Change text color.." New topic
Author

Change text color..

Ramesh Pramuditha Rathnayake
Ranch Hand

Joined: Oct 31, 2012
Posts: 169
    
    1

I want to change text color of a text component, not all the text, but some selected words only.
Eg:- This is the example text..

Is there a way to do this using any java JTextComponent...??


Ramesh-X
m Korbel
Ranch Hand

Joined: Jun 19, 2012
Posts: 150
Is there a way to do this using any java JTextComponent,

yes by using Html, then not only for JTextComponents, for all JComponents


for JTextComponents there are two ways

1. multiple of Highlighters for JTextPane/JEditorPane

2. Html, notice current Java support Html <= Html3.2 and with reduced support for css
Ramesh Pramuditha Rathnayake
Ranch Hand

Joined: Oct 31, 2012
Posts: 169
    
    1

How can I use html. Can you give me a link to refer..??
Kemal Sokolovic
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

How to Use HTML in Swing Components and How to Use Editor Panes and Text Panes would be a good place to start. These both contain examples that you can use as a reference.


The quieter you are, the more you are able to hear.
Ramesh Pramuditha Rathnayake
Ranch Hand

Joined: Oct 31, 2012
Posts: 169
    
    1

Thank you all for your help..
I got the answer..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Change text color..
 
Similar Threads
Change color of a LookAndFeel
How to make JComboBox flash (red color)?
selecting words from jtextpane (search)
Undeline in JTextPane
How to conditionally change text color?