Dennis
Dennis

Reputation: 87

Is there a way to set every other line in a java text area to a different color?

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.

Upvotes: 1

Views: 1239

Answers (1)

Andrew Thompson
Andrew Thompson

Reputation: 168825

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.

Upvotes: 1

Related Questions