0

Is there any way to change the background of a specific line of JTextArea?

Andrew Thompson
  • 166,747
  • 40
  • 210
  • 420
pedrohreis
  • 937
  • 2
  • 13
  • 33

1 Answers1

0

I found a class that does what I want. Those interested: http://www.camick.com/java/source/LinePainter.java

Thanks.

pedrohreis
  • 937
  • 2
  • 13
  • 33
  • Really, what's wrong with a `Highlighter`? – MadProgrammer Feb 19 '15 at 23:18
  • @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
  • @camickr Still scratching my head over the requirements :P – MadProgrammer Feb 20 '15 at 01:28
  • 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