3

Is it possible to have different rows in different colors in a textarea? Have you an example for that?

Gareth McCaughan
  • 19,888
  • 1
  • 41
  • 62
Wassim Sboui
  • 1,692
  • 7
  • 30
  • 48
  • possible duplicate of [How can I set partial text color in JTextArea?](http://stackoverflow.com/questions/2837848/how-can-i-set-partial-text-color-in-jtextarea) – Andrew Thompson Apr 30 '12 at 23:15
  • Here is an example about [How you can highlight in JTextArea](http://stackoverflow.com/a/10309277/1057230), though If you are more interested in changing the Foreground Colour, here is an example, [How to Change Text Colour with JTextPane](http://stackoverflow.com/a/9652143/1057230) – nIcE cOw May 01 '12 at 05:21

1 Answers1

12

Not with a JTextArea. You can, however, use a JTextPane which allows for attributes to be applied to text. If you want examples, take a look at the Text Component Tutorial.

Jeffrey
  • 44,417
  • 8
  • 90
  • 141