Overview of the Editor Kits

The following sections provide an overview of the various editor kits. With minor variations, this information applies to all editor kits.

The EditorKit Class

The EditorKit class is the abstract base class for all editor kits. It has a number of methods that define the model (e.g., createDefaultDocument( )), the view (e.g., getViewFactory( )), the capabilities (getActions( )), and the I/O strategy (read( ) and write( )) for a given type of document content. Figure 23-2 shows the EditorKit class and the many classes and interfaces it interacts with.

EditorKit class diagram

Figure 23-2. EditorKit class diagram

This figure shows several important things about the EditorKit class. First, each EditorKit instance is typically associated with a single JEditorPane (though in some cases, it doesn’t care). The EditorKit defines how to create a default Document as well as how to read and write the Document to a stream. In addition, each EditorKit may define a ViewFactory responsible for creating View objects for each Element in the Document. Finally, the diagram shows that an EditorKit may define a set of Actions that it supports.

The other classes shown in the diagram are the subclasses of EditorKit and AbstractAction. We’ll look at each of these classes, as well as some inner classes not shown on the diagram, throughout this chapter.

Properties

EditorKit defines the properties shown in Table ...

Get Java Swing, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.