1 26 27 package org.objectweb.util.browser.core.icon; 28 29 30 import org.objectweb.util.browser.core.api.FileIconProvider; 31 import org.objectweb.util.browser.core.common.ClassResolver; 32 33 34 import javax.swing.ImageIcon ; 35 36 37 import javax.swing.Icon ; 38 39 40 import java.net.MalformedURLException ; 41 import java.net.URL ; 42 43 51 public class DefaultFileIconProvider implements FileIconProvider { 52 53 54 protected Icon icon_ = null; 55 56 62 public Icon newIcon(Object object) { 63 return icon_; 64 } 65 66 71 public void setUrl(String url) { 72 if (url != null) { 73 URL urlFile = null; 74 urlFile = ClassResolver.getResource(url); 75 if(urlFile==null){ 76 try { 77 urlFile = new URL (url); 78 } catch (MalformedURLException e) { 79 System.out.println(getClass().getName() + url + ": Malformed URL !"); 80 } 81 } 82 if(urlFile!=null){ 83 icon_ = new ImageIcon (urlFile); 84 } 85 } 86 } 87 88 } 89 | Popular Tags |