Java ImageIcon(String filename) Constructor
Syntax
ImageIcon(String filename) constructor from ImageIcon has the following syntax.
@ConstructorProperties(value ="description")public ImageIcon(String filename)
Example
In the following code shows how to use ImageIcon.ImageIcon(String filename) constructor.
import java.awt.Image;
/* w w w . java2 s .c om*/
import javax.swing.ImageIcon;
public class Main {
public static void main(String[] a) {
ImageIcon imageIcon = new ImageIcon("yourFile.gif");
Image image = imageIcon.getImage();
}
}
Home »
Java Tutorial »
javax.swing »
Java Tutorial »
javax.swing »