I have a JTextPane
with a StyledDocument
and RTFEditorKit
implemented.
How can I add bullet points (preferrably multi-level ones) onto the JTextPane
?
I have a JTextPane
with a StyledDocument
and RTFEditorKit
implemented.
How can I add bullet points (preferrably multi-level ones) onto the JTextPane
?
Well it does not have built in support for this, however here is a great link with tutorial on creating bulleted and numbered lists in JTextPane
and JEditorPane
s:
Figured it out doing this:
HTMLEditorKit.InsertHTMLTextAction bulletAction = new HTMLEditorKit.InsertHTMLTextAction("Bullet", "<li> </li>", HTML.Tag.BODY, HTML.Tag.UL);
I know this is an old question, but what I have done is:
private final Action ORDERED_LIST_ACTION = new HTMLEditorKit.InsertHTMLTextAction("ORDERED-LIST", "<ol> </ol>", HTML.Tag.BODY, HTML.Tag.OL);
private final Action UNORDERED_LIST_ACTION = new HTMLEditorKit.InsertHTMLTextAction("UNORDERED-LIST", "<ul> </ul>", HTML.Tag.BODY, HTML.Tag.UL);
private final Action LIST_ITEM_ACTION = new HTMLEditorKit.InsertHTMLTextAction("BULLET", "<li> </li>", HTML.Tag.UL, HTML.Tag.LI, HTML.Tag.OL, HTML.Tag.LI);
When I have list creation and bullet creation as separate actions the interaction seems to work much better.