I don't want to set the entire text area to bold but just a selected single line. How would go about doing that?
Asked
Active
Viewed 4,797 times
1
-
See also this [example](http://stackoverflow.com/a/15600689/230513) using `JTextPane`. – trashgod Apr 26 '13 at 10:44
3 Answers
3
I suggest using a JTextPane instead as there are example solutions for it: http://docs.oracle.com/javase/tutorial/uiswing/components/editorpane.html http://www.java2s.com/Code/Java/Swing-JFC/JTextPaneStylesExample6.htm
2
There is no way to do it with JTextArea. You can achieve this with JEditorPane.
JEditorPane editorPane = new JEditorPane();
editorPane.setContentType("text/html");
editorPane.setText("<b>This text is bold</b>");

CodeBlue
- 14,631
- 33
- 94
- 132