I want to set color for specific lines in the text area. What I\'ve found so far, is the following
// Declarations
private final DefaultStyledDocument document;
Create a custom swing document extending for example PlainDocument and have a custom HighlightedView which is responsible for painting tokens.
I'm not sure if JTextArea can be styled in so much detail, since it presumably sets up styles for the whole document from the selected font, color etc. You may have more luck using a JTextPane/JEditorPane.
EDIT: From the javadoc
A JTextArea is a multi-line area that displays plain text.
(The emphasis is added.)
If you can move to JTextPane, then that will render the formatting.