Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bullet list in StyledDocument (JTextPane)

99 views
Skip to first unread message

Bjørn Børresen

unread,
Feb 19, 2004, 5:25:03 AM2/19/04
to

I would like to implement a bullet list in my JTextPane. I need to use a
DefaultStyledDocument for this, so a HTML won't do.

I'm amazed that this is something that needs to be done from scratch(?).

The way I was thinking of doing it:

- Overriding DefaultStyledDocument's insertString() method to insert a
"\n\u25CF\t" (new line + unicode for bullet + tab) whenever a \n is
recieved.
- Creating a custom TabStop that is used whenever there is a bullet list
- The Paragraph style in a bullet list must get a positive LeftIndent and a
negative FirstLineIndent to give the impression of 'hanging indent' that we
see in tab lists.

This solves some issues, but it's only the beginning.

- What happens when the user selects some text (including bullets) - the
bullets must behave like bullets, not just regular characters
- Deletion of lines
- Correct mouse/arrows navigation through bulleted paragraphs

Has anyone done this? Any hints? Code? :)

Best regards,
Bjørn Børresen
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

Jim Sculley

unread,
Mar 6, 2004, 12:15:31 AM3/6/04
to

A custom View, ViewFactory, etc. will probably be the cleanest way.

Jim S.

--
Remove my extraneous mandibular appendages to reply via email.

0 new messages