Search code examples
javaswingjtextarea

Swing JTextArea cannot show font type and color


I am developing a spam detector application using Java GUI (NetBeans). Now I have a simple user interface which includes a text area in which the user is going to paste his email in to order to check if its a spam or not, but the problem is when you paste a text in the text area all the text properties will be lost such as : Font type, color, hyperlinks etc...

So what should I do?


Solution

  • That's because you need RTF-enabled Swing component to visualize various text properties.

    JTextArea is visualizing only plain text. Use JEditorPane or JTextPane instead.