Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Java
Expertise: Intermediate
Feb 5, 1999

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()));
Tom Yarker
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date