The applet below attempts to load an image (from the associated Web page's folder)
into an ImageIcon and then use the ImageIcon 's paintIcon method to display the
image on the applet window.
public class ImageTest2a extends JApplet
private ImageIcon image;
public void init()
new ImageIcon(getDocumentBase(), " earth.gif");
public void paint(Graphics g)
Surprisingly, the above applet produces an empty display in the appletviewer and
in IE9! Chrome is also empty of any image, but shows a grey rectangle in the top
left corner, where the applet output would be, as shown in Fig. 12.12 .
Fig. 12.12 Output from applet ImageTest2a under Chrome when path to image fi le removed