1 5 package net.sf.panoptes.view.swing; 6 7 import java.net.URL ; 8 import java.util.HashMap ; 9 10 import javax.swing.ImageIcon ; 11 12 18 public class ImageCache { 19 20 private static HashMap imageCache = new HashMap (); 21 22 public static synchronized ImageIcon get(String iconName) { 23 ImageIcon icon = (ImageIcon ) imageCache.get(iconName); 24 if (icon == null) { 25 URL url = MainWindowSwing.class.getClassLoader().getResource(iconName); 26 icon = new ImageIcon (url); 27 imageCache.put(iconName, icon); 28 } 29 return icon; 30 } 31 } 32 | Popular Tags |