1 16 package net.sf.jftp.gui.framework; 17 18 import net.sf.jftp.system.logging.Log; 19 import net.sf.jftp.util.*; 20 21 import java.awt.*; 22 import java.awt.image.*; 23 24 import javax.swing.*; 25 26 27 public class HImage 28 { 29 public static synchronized Image getImage(Component c, String name) 30 { 31 Image img = null; 32 33 try 34 { 35 java.net.URL url = ClassLoader.getSystemResource(name); 36 37 if(url == null) 38 { 39 url = HImage.class.getResource("/" + name); 40 } 41 42 if(url == null) 45 { 46 url = HImage.class.getResource("/" + name.replace('\\', '/')); 47 } 48 49 img = (url != null) ? Toolkit.getDefaultToolkit().getImage(url) : null; 50 51 MediaTracker mt = new MediaTracker(c); 53 mt.addImage(img, 1); 54 mt.waitForAll(); 55 } 56 catch(Exception ex) 57 { 58 Log.debug("\n\n\nError fetching image!"); 59 ex.printStackTrace(); 60 61 return img; 64 } 65 66 return img; 67 } 68 69 public static synchronized ImageIcon getImageIcon(String name, String desc) 70 { 71 java.net.URL url = ClassLoader.getSystemResource(name); 72 73 if(url == null) 74 { 75 url = HImage.class.getResource("/" + name); 76 } 77 78 ImageIcon img = (url != null) ? new ImageIcon(url) : null; 80 81 return img; 82 } 83 } 84 | Popular Tags |