Java examples for 2D Graphics:Image
Creating a Gray Version of an Icon
import java.awt.Image; import javax.swing.GrayFilter; import javax.swing.Icon; import javax.swing.ImageIcon; public class Main { public Icon toGray(Icon icon) { if (icon instanceof ImageIcon) { Image grayImage = GrayFilter.createDisabledImage(((ImageIcon) icon).getImage()); return new ImageIcon(grayImage); }/* w ww. j a v a2s . co m*/ // Cannot convert return null; } }