Is there any way to change the background of a specific line of JTextArea
?
Asked
Active
Viewed 694 times
0

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

pedrohreis
- 1,030
- 2
- 14
- 33
-
I see this post, but I would like to change the color of the entire line and not only where there is text (like eclipse editor) – pedrohreis Feb 19 '15 at 22:29
-
http://stackoverflow.com/questions/5405550/highlight-current-row-in-jtextpane < Check this out. JTextPanes can do cooler stuff anyways. But, they also have their limitations. – IByrd Feb 19 '15 at 22:39
-
*" Is there any way to change the background of a specific line of `JTextArea`?"* Select the line. – Andrew Thompson Feb 20 '15 at 01:27
-
1@AndrewThompson, how does selecting it help? It only highlights the text, not the entire line. – camickr Feb 20 '15 at 01:29
1 Answers
0
I found a class that does what I want. Those interested: http://www.camick.com/java/source/LinePainter.java
Thanks.

pedrohreis
- 1,030
- 2
- 14
- 33
-
-
@MadProgrammer, the default HIghlighter doesn't paint the entire line, unless you use the `setDrawsLayeredHighlights(false)` property of the Highlighter. This would probably be the solution for static highlighting. If you want dynamic highlighting based on the caret location you can use the LinePainter. – camickr Feb 20 '15 at 01:24
-
-
1@MadProgrammer, the requirement is to highlight the background of the entire line, not just the background of the text. – camickr Feb 20 '15 at 01:33
-
@camickr *"background of a specific line"* - Is open to interruption ;) – MadProgrammer Feb 20 '15 at 01:38
-
@camickr get the idea, I wanted highlight the background of the entire line. Maybe I didn't express myself very well. – pedrohreis Feb 20 '15 at 03:05