Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

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



Application Security Testing: An Integral Part of DevOps

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() {
        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.



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