Fig. 12.11 Output from applet ImageTest1b under IE9
gif” in the appletviewer. However, the use of the abbreviated string fails to work in
each of Chrome and IE9, each displaying an empty page.
As will be seen in the next sub-section, ImageIcon s offer no more fl exibility than
Images (and, in fact, are even more restrictive). It would appear that the only reliable
way of using images in applets is to locate both images and applets in the same
directory on the Web server. In most cases, however, this is unlikely to be a particularly
Using Class ImageIcon
Now we can return to consideration of the problem with ImageIcon s referred to at
the start of Sect. 12.4 …
The ImageIcon constructor has nine different signatures, one of which takes the
following two arguments:
a URL, specifying the folder of the associated image;
the fi le name of the image.
It would appear from this that we can make use of method getDocumentBase
to specify the directory for an image fi le that is located in the same folder on the
Web server as the associated Web page (just as we did with method getImage in
the previous section).