Java ImageIcon createDisabledImage(final ImageIcon imageIcon)

Here you can find the source of createDisabledImage(final ImageIcon imageIcon)

Description

Creates a new grayed image based on the image passed in.

License

Open Source License

Parameter

Parameter Description
imageIcon Image icon to gray out

Return

New grayed out image

Declaration

private static ImageIcon createDisabledImage(final ImageIcon imageIcon) 

Method Source Code

//package com.java2s;
/**/*  w  w  w. jav a2 s .  c  o m*/
 * Copyright (C) 2011 Shaun Johnson, LMXM LLC
 * 
 * This file is part of Universal Task Executer.
 * 
 * Universal Task Executer is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option) any
 * later version.
 * 
 * Universal Task Executer is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * Universal Task Executer. If not, see <http://www.gnu.org/licenses/>.
 */

import javax.swing.*;
import java.awt.*;
import java.awt.image.FilteredImageSource;
import java.awt.image.ImageProducer;

public class Main {
    /**
     * Creates a new grayed image based on the image passed in.
     * 
     * @param imageIcon Image icon to gray out
     * @return New grayed out image
     */
    private static ImageIcon createDisabledImage(final ImageIcon imageIcon) {
        final GrayFilter filter = new GrayFilter(true, 75);
        final ImageProducer imageSource = imageIcon.getImage().getSource();
        final ImageProducer imageProducer = new FilteredImageSource(imageSource, filter);
        final Image grayImage = Toolkit.getDefaultToolkit().createImage(imageProducer);

        return new ImageIcon(grayImage);
    }
}

Related

  1. convert(ImageIcon icon)
  2. createBase64StringFromImage(ImageIcon image)
  3. createColorImageIcon(int w, int h, int c)
  4. createCursor(ImageIcon cursorIcon, Point hotSpot, String name)
  5. createCursor(ImageIcon icon, Point hotspot)
  6. createEmptyImageIcon(final int width, final int height)
  7. createFileImageIcon(final String path)
  8. createMonoColoredImageIcon(final Paint paint, final int width, final int height)
  9. createNonCachedImageIcon(File file)