You can use the
Text Component Line Number to display line numbers.
You can use a "Highlighter" to highlight the background of the text. Check out the "getHighlighter()" method of the JTextArea.
You may also want to take a look at the
Line Painter class. It will highlight the line where the caret currently is.
If you want to highlight the actual text, then you would need to use a JTextPane.