Click here to Skip to main content
15,890,741 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hello there, i'm trying to change the color of the text in a text area. Yes, i know how to change the color of an entire text, but how we can change the color of a specific word or text?

e.g.: "Java is a great programming language." and i want to change the "Java" word to red color and the rest remain in black.

thanks for the helping.
Posted

1 solution

Either instantiate the JTextArea using the constructor that accepts a Document as a parameter or use the setDocument method to provide a document model (such as HTML) that will allow you to do fancy formatting.
Here is a link[^] to the documentation for Document. It should provide a starting point for you.
 
Share this answer
 
Comments
[no name] 10-May-11 10:31am    
thanks ...this is really what i wanted. Thanks for the work, now it's my time to work...
Marc A. Brown 10-May-11 10:34am    
Awesome. Glad I could help. Don't forget to accept the answer!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900