static public void setHTMLEditorKit(JEditorPane editorPane) {
        editorPane.getDocument().putProperty("imageCache", imageCache); // Read internally by ImageView, but never written.
        // Extend all this shit to cache images.
        editorPane.setEditorKit(new HTMLEditorKit() {
            private static final long serialVersionUID = -562969765076450440L;

            public ViewFactory getViewFactory() {
                return new HTMLFactory() {
                    public View create(Element elem) {
                        Object o = elem.getAttributes().getAttribute(StyleConstants.NameAttribute);
                        if (o instanceof HTML.Tag) {
                            HTML.Tag kind = (HTML.Tag) o;
                            if (kind == HTML.Tag.IMG) return new ImageView(elem) {
                                public URL getImageURL() {
                                    URL url = super.getImageURL();
                                    // Put an image into the cache to be read by other ImageView methods.
                                    if (url != null && imageCache.get(url) == null)
                                        try {
                                            imageCache.put(url.toURI(), Toolkit.getDefaultToolkit().createImage(url));
                                        } catch (URISyntaxException e) {
                                        }
                                    return url;
                                }
                            };
                        }
                        return super.create(elem);
                    }
                };
            }
        });
    }