4

I have a jTextPane that has HTMLEditorKit set as the default editorKit. Calling getDocument on the jTextPane returns an HTMLDocument. I can traverse through this Document, navigating around the elements, but I can't seem to find a way to actually get the text contents of individual elements. I know in the DOM, there is a getTextContents() on each element, but I'm not working with the W3C DOM.

Corey Farwell
  • 1,856
  • 3
  • 14
  • 19

1 Answers1

3

As you traverse the document's ElementIterator, shown here, use the getStartOffset() and getEndOffset() of each Element to calculate the parameters needed to call getText().

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045