Java ImageIcon getDisabledIcon(ImageIcon icon)

Here you can find the source of getDisabledIcon(ImageIcon icon)

Description

Replies the disabled (grayed) version of the specified icon.

License

GNU General Public License

Parameter

Parameter Description
icon The icon to disable

Return

The disabled (grayed) version of the specified icon, brightened by 20%.

Declaration

public static final ImageIcon getDisabledIcon(ImageIcon icon) 

Method Source Code

//package com.java2s;
// License: GPL. For details, see LICENSE file.

import java.awt.Image;

import java.awt.Toolkit;

import java.awt.image.FilteredImageSource;

import javax.swing.GrayFilter;

import javax.swing.ImageIcon;

public class Main {
    /**// ww  w.  ja  v  a2s  . c  om
     * Replies the disabled (grayed) version of the specified icon.
     * @param icon The icon to disable
     * @return The disabled (grayed) version of the specified icon, brightened by 20%.
     * @since 5484
     */
    public static final ImageIcon getDisabledIcon(ImageIcon icon) {
        return new ImageIcon(getDisabledImage(icon.getImage()));
    }

    /**
     * Replies the disabled (grayed) version of the specified image.
     * @param image The image to disable
     * @return The disabled (grayed) version of the specified image, brightened by 20%.
     * @since 5484
     */
    public static final Image getDisabledImage(Image image) {
        return Toolkit.getDefaultToolkit()
                .createImage(new FilteredImageSource(image.getSource(), new GrayFilter(true, 20)));
    }
}

Related

  1. fitIcon(ImageIcon icon, int containerWidth, int containerHeight)
  2. fitToSquare(ImageIcon icon, int newSize)
  3. generateImageIcon(Color color, int size, Insets insets)
  4. getBorderedIcon(ImageIcon icon)
  5. getByteImage(ImageIcon icon)
  6. getHeight(ImageIcon imagen)
  7. getOpenSwingImage(String name, ImageIcon defaultIcon)
  8. getRenderedImage(ImageIcon icon)
  9. getSizeOfImage(ImageIcon imgIn)