The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > java.awt  [78 examples] > Images  [4 examples]

e597. Creating a Gray Version of an Icon

    public Icon toGray(Icon icon) {
        if (icon instanceof ImageIcon) {
            Image grayImage = GrayFilter.createDisabledImage(((ImageIcon)icon).getImage());
            return new ImageIcon(grayImage);
        }
        // Cannot convert
        return null;
    }

 Related Examples
e594. Reading an Image or Icon from a File
e595. Drawing an Image
e596. Scaling, Shearing, Translating, and Rotating a Drawn Image

See also: Colors    Components    Containers    Cursors    Drawing    Events    Focus    Frames    GridBagLayout    Shapes    Simulating Events    Text    The Screen   


© 2002 Addison-Wesley.