QHTML Demo

What Is It

This is set of classes that extends Java's default HTML Swing renderer to support newer CSS features (discussed below).

This doesn't fully support any particular CSS version, so this is not intended to be used for arbitrary pages. The intended usage for these classes is to present HTML that you have complete control over, such as a set of help pages.

How To Use It

Installing this architecture is simple:

JEditorPane textPane = new JEditorPane();
HTMLEditorKit kit = new QHTMLEditorKit();
textPane.setEditorKit(kit);

How It Works

This extends Swing's existing HTMLEditorKit to support newer CSS features.

Discussion

Context

Swing has included HTML support for decades, but it has been conspicuously limited (and therefore dated). The QHTMLEditorKit is an attempt to spruce up the appearance of the HTML without completely reinventing the rendering engine.

Other resources you might want to consider include:

  1. Flying Saucer can also render HTML to Swing panels (in addition to other formats).
  2. JavaFX can embed a WebKit in a JComponent. The underlying implementation varies by platform.

Feature Support

Below is a (approximate) set of features the QHTML classes support:

Also these classes support base64-encoding of our custom JVG file format, which is used in some of the help documentation in the showcase app to embed vector graphics.