File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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
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: 155
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..
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Change text color..