Here you can find the source of createDisabledImage(final ImageIcon imageIcon)
Parameter | Description |
---|---|
imageIcon | Image icon to gray out |
private static ImageIcon createDisabledImage(final ImageIcon imageIcon)
//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); } }