Java Reference
In-Depth Information
is available for the JEditorPane when its content type is text/html . For restricting input into
any of these documents, you can use the DocumentFilter class.
Figure 15-1. Swing text component class hierarchy diagram
Many other classes to be discussed in this chapter and in Chapter 16 are common among
the text components. As with many of the other Swing components, you can customize the
look and feel of the components without creating a new UI delegate. For the text components,
the Highlighter , Caret , and NavigationFilter interfaces describe how text is highlighted, where
text is inserted, and how to limit cursor positioning, respectively, thus allowing you to customize
the text component appearance and input behavior. In addition, the InputMap / ActionMap
classes define the bindings between keystrokes and text actions, letting you alter the feel of text
components very easily.
Other text component model pieces are designed for event handling. You are not limited
to using the KeyListener / KeyEvent or TextEvent / TextListener combination for dealing with
input validation. The Swing components also can use the DocumentEvent / DocumentListener
combination (as well as the InputVerifier described in Chapter 2). This combination provides
a much more flexible manner of input validation, especially in the MVC environment of the Swing
text components. Additional event handling is done through an extension of the AbstractAction
capabilities introduced in Chapter 2. This is the TextAction class for tying key bindings to Action
implementations, which is discussed in detail in Chapter 16. Many of the text framework pieces are
tied together by what is called an EditorKit , which is also discussed in Chapter 16.
Note Due to the many interconnections among the Swing text component classes, you'll find a number of
references in this chapter to Chapter 16. Feel free to jump between this chapter and the next to read up on
the full details of a particular capability.
 
Search WWH ::




Custom Search