I have a JTextPane
, and I would like to output text on it using StyledDocument
. Here is my StyledDocument
object
StyledDocument dox = (StyledDocument) textArea.getDocument();
Style style = dox.addStyle("StyleName", null);
StyleConstants.setFontFamily(style, Font.SANS_SERIF);
StyleConstants.setFontSize(style, 8);
dox.insertString(dox.getLength(), "<b>Some Text</b>", null);
The problem right now is if I edit the text with html code, it does not display the way I want. I want the text to be displayed as bolded instead of literally "Some Text".
Is there a way to do this?