Reputation: 11
I don't want to set the entire text area to bold but just a selected single line. How would go about doing that?
Upvotes: 1
Views: 4857
Reputation:
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
Upvotes: 3
Reputation: 31647
According to the documentation of JTextArea,
A
JTextArea
is a multi-line area that displays plain text.
plain text, in this sense, means every character is formated the same way. There is no way to format some characters differently than other characters.
Upvotes: 1
Reputation: 15389
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>");
Upvotes: 2