I would like to alternate between gray and white as background from one line of my JTextPane to the next.
I tried to do this by overloading the paintComponent() method and drawing the background manually according to component height an Font size but I did not succeed.
Any hints?
You can use the line highlighter (here or here), written by @VonC, in response to this question.
In order to highlight alternate lines you can use it as follows:
Here is VonC’s
MyHighlighter: