void (Icon icon) { if (icon == null) return; // todo: the context should belong to the device the icon is displayed on ScaleContext ctx = ScaleContext.create(); // make sure the icon is in JB format icon = MultiResolutionImageProvider.convertFromMRIcon(icon, ctx); int w = icon.getIconWidth(); int h = icon.getIconHeight(); if (w <= 0 || h <= 0) return; BufferedImage image = IconUtil.toBufferedImage(icon, ctx, false); if (image.getType() != BufferedImage.TYPE_INT_ARGB_PRE) { BufferedImage newImage = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB_PRE); Graphics2D g = newImage.createGraphics(); try { g.setComposite(AlphaComposite.Src); UIUtil.drawImage(g, image, 0, 0, null); } finally { g.dispose(); } image = newImage; } int[] bytes = ((DataBufferInt)image.getRaster().getDataBuffer()).getData(); ensureNativePeer(); nativeSetImage(nativePeer, bytes, w, h, image.getWidth(), image.getHeight(), isInHierarchy); }