| 1 16 17 package org.mc4j.console.swing.html; 18 19 import javax.swing.text.html.ImageView ; 20 import javax.swing.text.html.HTML ; 21 import javax.swing.text.Element ; 22 import java.net.URL ; 23 24 28 public class ClassPathImageView extends ImageView { 29 public ClassPathImageView(Element elem) { 30 super(elem); 31 } 32 38 public URL getImageURL() { 39 String src = (String )getElement().getAttributes(). 40 getAttribute(HTML.Attribute.SRC); 41 URL url = null; 42 43 if (src.startsWith("classpath://")) { 44 String location = src; 45 location = location.substring(12,location.length()); 46 url = getClass().getClassLoader().getResource(location); 47 return url; 48 } else { 49 return super.getImageURL(); 50 } 51 } 52 } 53 | Popular Tags |