Designating Disabled Icons

Designating Disabled Icons

To show when an icon button is disabled, you need to have a less prominent version of the icon’s image. The following class reduces the alpha component of each color in the original image. This is more efficient than adjusting the red, green and blue components individually, because the change can be applied to the image’s palette:

 import java.awt.image.*;public class Dimmer extends RGBImageFilter {// Constructor.    public Dimmer() {        super();        canFilterIndexColorModel = true;    }// Adjusts color of pixel or palette entry.    public int filterRGB(int x, int y, int rgb) {        return rgb & 0x5fffffff;    }}

To use this filter to produce a phantom image just requires:

 Image original, ghost;...ghost = createImage(new FilteredImageSource(        original.getSource(), new Dimmer()));
See also  5 Tips for Choosing the Right Medical Software for Your Practice

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist