14.12. The JEditorPane Component

JEditorPane is sort of a fancy text area that can display text derived from different file formats. The built-in version supports HTML and RTF (Rich Text Format) only, but you can build “editor kits” to handle special-purpose applications. In principle, you choose the type of document you want to display by calling setContentType, and you specify a custom editor kit through setEditorKit. Note that unless you extend the JEditorPane class, the only legal choices are text/html, text/plain, (which is also what you get if you supply an unknown type), and text/rtf.

In practice, however, JEditorPane is almost always used for displaying HTML. If you have plain text, you might as well use JTextField. RTF support is currently ...

Get Core Web Programming, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.