static int imageIcon_cacheSize = 10; sbool imageIcon_verbose; static Map imageIcon_cache; static Lock imageIcon_lock = lock(); // not going through BufferedImage preserves animations static ImageIcon imageIcon(S imageID) ctex { lock imageIcon_lock; if (imageIcon_cache == null) imageIcon_cache = new MRUCache(imageIcon_cacheSize); imageID = fsI(imageID); ImageIcon ii = imageIcon_cache.get(imageID); if (ii == null) { if (imageIcon_verbose) print("Loading image icon: " + imageID); File f = loadBinarySnippet(imageID); ifndef DontFixGIFs ii = new ImageIcon(loadBufferedImageFixingGIFs(f)); endifndef ifdef DontFixGIFs ii = new ImageIcon(f.toURI().toURL()); endifdef } else imageIcon_cache.remove(imageID); // move to front of cache on access imageIcon_cache.put(imageID, ii); ret ii; } static ImageIcon imageIcon(Image img) { ret new ImageIcon(img); } ifclass RGBImage static ImageIcon imageIcon(RGBImage img) { ret imageIcon(img.getBufferedImage()); } endif