1
16package org.tp23.antinstaller.renderer.swing;
17
18import java.net.URL;
19
20import javax.swing.text.Element;
21import javax.swing.text.View;
22import javax.swing.text.ViewFactory;
23import javax.swing.text.html.HTML;
24import javax.swing.text.html.HTMLEditorKit;
25import javax.swing.text.html.ImageView;
26
31public class ClasspathHTMLEditorKit extends HTMLEditorKit {
32
33 public ViewFactory getViewFactory(){
34
35 return new HTMLEditorKit.HTMLFactory(){
36
37 public View create(Element elem){
38 if(! elem.getName().equals("img")){
39 return super.create(elem);
40 }
41 return new ImageView(elem){
42 public URL getImageURL() {
43 String src = (String)getElement().getAttributes().
44 getAttribute(HTML.Attribute.SRC);
45 return TextPageRenderer.class.getResource(src);
46 }
47 };
48 }
49
50 };
51
52 }
53
54}
55