static int imageIcon_cacheSize = 10; sbool imageIcon_verbose; static Map imageIcon_cache; static Lock imageIcon_lock = lock(); 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); ii = new ImageIcon(loadBinarySnippet(imageID).toURI().toURL()); } else imageIcon_cache.remove(imageID); // move to front of cache on access imageIcon_cache.put(imageID, ii); ret ii; } static ImageIcon imageIcon(BufferedImage img) { ret new ImageIcon(img); } ifclass RGBImage static ImageIcon imageIcon(RGBImage img) { ret imageIcon(img.getBufferedImage()); } endif