Dies ist eine alte Version des Dokuments!
Icon zu Image konvertieren
Folgenden kleine Methode konvertiert ein Icon zu einem Image:
public Image iconToImage(Icon icon) { if (icon instanceof ImageIcon) { return ((ImageIcon)icon).getImage(); } else { int width = icon.getIconWidth(); int height = icon.getIconHeight(); BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = (Graphics2D) image.getGraphics(); icon.paintIcon(null, g, 0, 0); return image; } }