I am just getting started with JTextPane, so bear with me if the question is
not advanced enough.

In the simple examples of using JTextPane that I see, we can assign a
particular style to the portion of the document using the position (offset)
of the that piece of text.

doc.insertString(doc.getLength(), myTextString, textPane.getStyle("red"));

However, when the document changes, how do we keep track of the position of
the styled text in a document? Of course I can have a simple caret position
variable and increment/decrement it every time the document changes. But I
am sure there's a better and more efficient way defined in Swing. Can
someone help/provide a simple example?

The reason for this question is that I need to store the style represented
by XML tags behind the scenes (not visible to the end user) and associate it
with a piece of text in the document.

Thanks.

-Lenny, 
 Goldman, Sachs & Co.
 New York, USA


_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing

Reply via email to