Icon (Color color) { Icon icon = icons_cache.get(color); if (icon != null) return icon; final BufferedImage image = GraphicsEnvironment.getLocalGraphicsEnvironment() .getDefaultScreenDevice().getDefaultConfiguration() .createCompatibleImage(16, 16, Transparency.TRANSLUCENT); final Graphics g = image.getGraphics(); g.setColor(color); g.fillRect(0, 0, 16, 16); g.dispose(); icon = new ImageIcon(image); icons_cache.put(color, icon); return icon; }