I have a JTextPane
with a StyledDocument
and RTFEditorKit
implemented.
我有一个带有StyledDocument和RTFEditorKit的JTextPane。
How can I add bullet points (preferrably multi-level ones) onto the JTextPane
?
如何在JTextPane上添加项目符号(最好是多级项目符号)?
3 个解决方案
#1
3
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:
好吧,它没有内置支持,但是这里有一个很好的链接,在JTextPane和JEditorPanes中创建项目符号和编号列表的教程:
- Bullets and Numberings in the JEditorPane/JTextPane.
JEditorPane / JTextPane中的项目符号和编号。
#2
2
Figured it out doing this:
弄清楚这样做:
HTMLEditorKit.InsertHTMLTextAction bulletAction = new HTMLEditorKit.InsertHTMLTextAction("Bullet", "<li> </li>", HTML.Tag.BODY, HTML.Tag.UL);
#3
0
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.
当我将列表创建和项目符号创建作为单独的操作时,交互似乎工作得更好。
#1
3
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:
好吧,它没有内置支持,但是这里有一个很好的链接,在JTextPane和JEditorPanes中创建项目符号和编号列表的教程:
- Bullets and Numberings in the JEditorPane/JTextPane.
JEditorPane / JTextPane中的项目符号和编号。
#2
2
Figured it out doing this:
弄清楚这样做:
HTMLEditorKit.InsertHTMLTextAction bulletAction = new HTMLEditorKit.InsertHTMLTextAction("Bullet", "<li> </li>", HTML.Tag.BODY, HTML.Tag.UL);
#3
0
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.
当我将列表创建和项目符号创建作为单独的操作时,交互似乎工作得更好。