Reputation:
I have a problem with JTextArea. I dont know how can I change part of my text in JTextArea to be bold or to be cursive. Anyone?
Upvotes: 0
Views: 880
Reputation: 3679
Use Simple Attributes
to change the text font and color. like
SimpleAttributeSet attrSet= new SimpleAttributeSet();
StyleConstants.setFontFamily(attrSet, "Courier New Italic");
StyleConstants.setForeground(attrSet, Color.BLUE);
textArea.getDocument().insertString(0, "Your text is here", attrSet);
and alternatively, you will get much more advantage and flexibility, if you use editor or text panes.
Upvotes: 1