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()));