Hi friend,
I suggest you to go through the following example of 'ImageIcon class'
Code:
import javax.swing.ImageIcon;
public class ImageIconDM {
public static void main(String[] ank) {
JFrame clW = new JFrame();
clW.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ImageIcon icon = new ImageIcon("yourFile.gif");
Image normalImage1 = icon.getImage();
Image grayImage1 = GrayFilter.createDisabledImage(normalImage1);
Icon warningIcon1 = new ImageIcon(grayImage1);
JLabel warningLabel1 = new JLabel(warningIcon1);
JLabel label03 = new JLabel("Warning", icon, JLabel.CENTER);
clW.add(warningLabel1,"Center");
clW.add(label03,"South");
clW.setSize(400, 200);
clW.setVisible(true);
}
Bookmarks