Java GrayFilter .createDisabledImage (Image i)
Syntax
GrayFilter.createDisabledImage(Image i) has the following syntax.
public static Image createDisabledImage(Image i)
Example
In the following code shows how to use GrayFilter.createDisabledImage(Image i) method.
import java.awt.Image;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
/*ww w. j av a 2 s.c om*/
import javax.swing.GrayFilter;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Main extends JFrame {
public Main() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel p = new JPanel();
ImageIcon icon = new ImageIcon("r.gif");
JButton b1 = new JButton("Regular", icon);
p.add(b1);
Image image = GrayFilter.createDisabledImage(icon.getImage());
JButton b2 = new JButton("GrayFilter", new ImageIcon(image));
p.add(b2);
getContentPane().add(p);
pack();
setVisible(true);
}
public static void main(String arg[]) {
new Main();
}
}
Home »
Java Tutorial »
javax.swing »
Java Tutorial »
javax.swing »