Java Reference
In-Depth Information
JEditorPane Class
The JEditorPane class provides the ability to display and edit multiple-attributed text. While
the JTextField and JTextArea support only single-color, single-font content, the JEditorPane
allows you to tag your content with various styles (such as bold, italics, 14-point Helvetica,
right-justified paragraphs) or with the appearance of an HTML viewer, as shown in Figure 15-19.
Figure 15-19. Sample JEditorPane as an HTML viewer
Note The HTML support for JEditorPane is only at the HTML 3.2 level with some extensions, whereas
HTML 4.0x is the current version as of this writing. Cascading Style Sheets (CSS) are partially supported.
The JEditorPane supports the display and editing of multiple-attributed text through the
help of an EditorKit specific to the text-markup mechanism. Predefined kits exist to support
raw text, HTML documents, and Rich Text Format (RTF) documents. Because the content is
multiple-attributed, the PlainDocument model is no longer sufficient. Instead, Swing provides a
StyledDocument in the form of the DefaultStyledDocument class for maintaining the document
model. The remaining part of the mix is the new HyperlinkListener / HyperlinkEvent event-
handling pair for monitoring hyperlink operations within the document.
 
Search WWH ::




Custom Search