
CHAPTER 30
Thejavax.swing.text Package
This large and complex package contains the powerful JTextComponent text editor
and all of its supporting infrastructure. The JTextF ield, JTextArea, JEditorPane, and other
text input components of the javax.swing package all subclass JTextComponent and
rely on the other classes and interfaces of this package.
The Document inter face defines the data model for the JTextComponent.Itisthe basic
abstraction for documents that can be displayed and edited. The AbstractDocument
class implements this interface and provides a number of useful features and
extensions. StyledDocument extends Document to define support for documents that
have styles associated with their content. DefaultStyledDocument is a concrete imple-
mentation based on AbstractDocument. Other important classes and interfaces in this
package include: EditorKit, Element, View, AbstractDocument.Content, Caret, and High-
lighter. Figur e 30-1 shows the class hierarchy of this package.
AbstractDocument Ja va 1.2
javax.swing .text serializable
This class is a partial, abstract implementation of the Document inter face, which also
defines several important inner classes and interfaces. Typical applications do not have
to use or subclass this class. Instead, they can rely on predefined concrete implementa-
tions such as PlainDocument, DefaultStyledDocument, and javax.swing .text.html.HTMLDocument.
public abstract ...