Applets
Locating Resource
Creating ImageIcon Using Absolute File Names
You used the ImageIcon class to create an icon from an image file and the setIcon method or the constructor to place the image in a GUI component, such as a button and a label. For example, the following statements create an ImageIcon and set it on an JLabel object jlbl.
ImageIcon imageIcon = new ImageIcon("c:\\book\\image\\us.gif"); jlbl.setIcon(imageIcon);
This approach suffers a problem. The file location is fixed since it uses the absolute file path on Window. Thus, the program cannot run on other platforms and cannot run as applet.