byte[] (Icon icon) { if (icon == null || icon.getIconWidth() <= 0 || icon.getIconHeight() <= 0) { return null; } final BufferedImage img = ImageUtil.createImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB); final Graphics2D g2d = img.createGraphics(); icon.paintIcon(null, g2d, 0, 0); g2d.dispose(); final ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { ImageIO.write(img, "png", bos); return bos.toByteArray(); } catch (IOException e) { LOG.error(e); return null; } }