0

In a JTextPane with a DefaultStyledDocument the document structure (hierarchy of Element objects) ends with a LeafElement that spans all the character of the enclosing paragraph. Is there a way to customize the document such that each leaf element will represent a single character?

(Background: I am trying to implementing a custom coloring scheme - somewhat similar to syntax coloring in an IDE. Using setCharacterAttributes() for this purpose is not an option, mainly due to performance considerations.)

4

1 回答 1

0

You may be interested in jsyntaxpane. It uses a PlainDocument instead of using the more resource hungry StyledDocument. A Leaf for each character will require lots of memory, so you may want to use a leaf for each "Token".

You can also use a StyledDocument then update the style for each Token in a separate Thread.

于 2009-03-17T17:19:13.670 回答