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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.