File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Storm Applied this week in the Other Open Source APIs forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Simple STRING Question!" Watch "Simple STRING Question!" New topic

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

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

Joined: Dec 11, 2004
Posts: 13410

The JEditorPane supports HTML and Rich Text:

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.

I agree. Here's the link:
subject: Simple STRING Question!