JTextArea – How to add Code/Syntax highlighting?

Issue

Im developing an app in java, a simple text editor. What I want to do is to add syntax highlighting, so it will color java (pubic, static, void, int, float). How can I do that? Thanks.

Solution

You can take a look at this old discussion, but it sounds tricky.
Check this out.
But I don’t know if JTextArea is what you’re looking for, read some docs for JTextPane or JEditorPane. You may want to use them.

Answered By – gpicchiarelli

Answer Checked By – Marie Seifert (AngularFixing Admin)

Leave a Reply

Your email address will not be published.