I am trying to understand the purpose of Element and how this can help with the manipulation of the StyledDocument , which should appear in JEditorPane or JTextPane. I am also trying to understand how this relates to the term “paragraph”.
javadoc for javax.swing.text.Element almost nothing:
public interface Element
An interface for describing the structural part of a document. It is designed to capture the spirit of the SGML element.
I am very familiar with the concept of an element in HTML and XML, and apparently this is something similar, but I just do not see its purpose, since this applies to StyledDocument. At first, I realized that it was just something that StyledDocument used internally to control stops and starting points of different styles, but then I saw code examples on the Internet where they used Element instances.
I already have my own tree-like data structure that I need to display in different fonts and colors, and after going through it, I will say where you can change the font or color as necessary. It seems that I can satisfy the immediate need for a series of calls to StyledDocument.setCharacterAttributes and setParagraphAttributes without touching the element itself.
, Element . , StyledDocument , , - , , , , .