How to display bold text in only parts of JTextArea?

No. What you’re looking for is JEditorPane

This supports HTML (3.2?) which will allow you to use <font> (and other older tags) to provide rich text.

JEditorPane textarea = new JEditorPane("text/html", "");
textarea.setText("Here is some <b>bold text</b>");

EDIT: According to the javadoc I referenced above, JEditorPane also supports limited RTF. Don’t forget to change the MIME to text/rtf

Leave a Comment