Search code examples
javaswingjtextarea

How to draw line in JTextArea and change color of a specific words


I'm currently developing JTextArea with a Notepad++ like function (currently indentation function finished).

Now I'm trying to add a function which in my JTextArea will show a dotted line for an indentation with same level, and change specific color of a word.

Thanks in advance :)


Solution

  • You will not able to achieve your target with JTextArea as it is a plain text support component.You have to use a Styled text supported JEditorPane or JTextPane.And try to use a HTML document and achieve it.Look at

    Styled supported components

    and

    some more examples