1

I'm making myself a little messenger just for fun. And I want to make it so that when you see a certain word in there, for example your username it will be blue.

for example it will look something like this:

User1: Hello how are you?
User2: I'm fine thanks, what about you :)

(bold = blue, not bold = black)

This is how my client looks at the moment: The window

Anyway.. I hope this information will be enough for you to understand my question/ problem. Thanks :)

Shaun Wild
  • 1,237
  • 3
  • 17
  • 34
  • 1
    Please have a look at this example, [How to colour specific Text Literels using JTextPane](http://stackoverflow.com/questions/9650992/how-to-change-text-color-in-the-jtextarea/9652143#9652143) – nIcE cOw Jun 26 '12 at 03:19

1 Answers1

5

I'm afraid that JTextArea cannot contain HTML tags to change text color. It was designed to store plain text only. You might have to use JTextPane. Official info: http://docs.oracle.com/javase/tutorial/uiswing/components/text.html

Adam Sznajder
  • 9,108
  • 4
  • 39
  • 60