Skip to Main Content
Java Swing, 2nd Edition
book

Java Swing, 2nd Edition

by Dave Wood, Robert Eckstein, Marc Loy, James Elliott, Brian Cole
November 2002
Intermediate to advanced content levelIntermediate to advanced
1278 pages
38h 26m
English
O'Reilly Media, Inc.
Content preview from Java Swing, 2nd Edition

HTML and JEditorPane

As we discussed in Chapter 19, Swing provides (somewhat spotty) support for working with the Web’s most common markup language, HTML. Fortunately, as Swing matures, the HTML support in the JEditorPane class improves.

The support for reading, writing, and displaying HTML through the JEditorPane class is provided by the HTMLEditorKit and associated classes. This class is an extension of the generic DefaultEditorKit class and is devoted (not surprisingly) to HTML files. You might recall from the previous discussion of EditorKit that there are three basic parts of an editor kit: its parser, its file writer, and its association with a ViewFactory. While we have looked briefly at these pieces before, here we focus on their implementation in HTMLEditorKit.

Along the way, we’ll see how to extend some of these pieces to do custom work in the context of an HTML document. We decided that a detailed discussion of the classes that extend the editor kit would not be interesting to a majority of our readers, so we concentrate on the more immediately useful classes. However, if you want to see the details and play with the internals of the HTMLEditorKit, we have two entire chapters devoted to this topic on the book’s web site (http://www.oreilly.com/catalog/jswing2). Throughout this discussion, we’ll point you to that material if you want more detail than we’ve provided here.

Much of the information in those chapters describes how you can extend HTML with custom tags. Adding ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java Threads, 3rd Edition

Java Threads, 3rd Edition

Scott Oaks, Henry Wong

Publisher Resources

ISBN: 0596004087Errata PageSupplemental Content