This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Java in General and the fly likes Simple STRING Question! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Simple STRING Question!" Watch "Simple STRING Question!" New topic
Author

Simple STRING Question!

Mike Smike
Ranch Hand

Joined: Aug 25, 2004
Posts: 33
Hi guys,

I've searched the forums and the API, but I can't find what I'm looking for!

I have say, a JTextArea, in which there are some strings. My problem is that I want the strings to be different colours. The only method I can find it the setForeGround(Color c) for the JTextArea, but this is no good as it colours all the text the same!

Surely there is a way to colour individual letters/words/strings differently??

If there isn't - please let me know. I found a post from 2001 asking something similar but with no answers! eek

Please help

Thanks for your time

Mike
[ February 17, 2005: Message edited by: Mike Smike ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

The JEditorPane supports HTML and Rich Text:
http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JEditorPane.html


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Lionel Badiou
Ranch Hand

Joined: Jan 06, 2005
Posts: 140
Hi Mike,

- Take a look at
Using text Components

- jEditorPane (or jTextPane) should meet your needs.

Hope that helps,


Lionel Badiou
CodeFutures Software
Mike Smike
Ranch Hand

Joined: Aug 25, 2004
Posts: 33
Thankyou muchos amigos! Very much appreciated. I will have a look at these JEditorPane and JTextPane things.

Mike
 
 
subject: Simple STRING Question!