Swing HTML Preview
That the standard Java Swing text components can render HTML is mighty
handy. That they're ornery and underdocumented (as far as what HTML
tags/attributes and CSS styles they support) is annoying. Essentially,
you've got to try things out to see how they'll look.
So I made this little class to make experimentation easier. Run the
executable JAR, and you'll get a window with two text areas. The top,
editable, will take your raw HTML. The bottom, not edittable, will
live-render your HTML, as each keystroke comes in.
- Cut, Copy, and Paste keyboard shortcuts seem to work.
- Some illegal (or more likely in-the-process-of-being-typed) HTML chokes
the renderer. Thrown error are silently caught, and a re-render is
attempted with each new keystroke. However, as long as there are
problems the insertion caret will appear in red and the HTML view may
- You probably want to type IMG SRC values elsewhere, then paste them
into the right place. Otherwise, each character of the SRC URL as it is
being typed will cause slow-timeout fetch errors before the URL is legal.
Swing HTML Preview Files
Executable JAR (created under Java 1.3.1, will probably work elsewhere):
SwingHTMLPreview.jar, 1,926 bytes [Bitzi: F27Y...]
SwingHTMLPreview.java, 2,647 bytes [Bitzi: I7CJ...]