1

I want to set every other line in a java text area to a second color, is there a way to do this?

example:

<red>1</red>    
<blue>2</blue>
<red>3</red>    
<blue>4</blue>

the red and blue tags are just for example only.

Dennis
  • 87
  • 3

1 Answers1

1

Neither java.awt.TextArea nor javax.swing.JTextArea support text (or background) decorations. It is one font & one style.

As indicated by Chris, a JTextPane (or JEditorPane) is designed for 'styled text' documents. JEP for example, will handle RTF & (simple) HTML/CSS formatting.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433