Next: Document significant methods
Up: Text In Swing
Previous: Other JTextComponent significant methods
Swing needs to respond some special types of events to handle
text changes and formatting -- it does this with a class named Document.
Note: In the Swing MVC architecture, the Document class serves as a model.
It
contains no capability for user interface.
These functions originate with the
users of this class, such as JTextField and JTextArea.
The Document class:
- a Swing-based container used to hold text and to provide
notification of changes to this text.
- implements support for
mark-up (text selection)
- includes an internal structure to manage changes to its
text.
- The structure of these elements consists of a base unit
of containment called an element, each of which includes an arbitrary set of
attributes associated with its text.
- Root Element
- Line/Paragraph Line/Paragraph
- Content Element Break Content Element Break
- Typically, an instance of Document will contain
only a single element structure, but the interface supports building any number of
structural projections over the text element.
- Document supports multiple
root elements and multiple data structures.
- For example, suppose you need to store
modification notes or annotations along with the text.
- you need to create
an additional data structures associated with the annotations, in addition to
structure that contains the actual text.
Next: Document significant methods
Up: Text In Swing
Previous: Other JTextComponent significant methods
Dave Marshall
4/14/1999