Java Reference
In-Depth Information
Images and Sounds
Example 15-6 shows a Java applet that implements a simple client-side imagemap
that can highlight the “hot spots” in the image and play a sound clip when the
user clicks on the image. Figure 15-3 shows what this applet might look like,
when configured with an appropriate image.
Figur e 15−3. An imagemap applet
This applet demonstrates quite a few important applet techniques:
•
The getParameter()
method looks up the name of the image to display and
the audio clip to play when the user clicks, and it also reads a list of rectan-
gles and URLs that define the hot spots and hyperlinks of the imagemap.
•
The
getImage()
and
getDocumentBase()
methods load the image (an
Image
object) in the
init()
method, and
Graphics.drawImage()
displays the image
in the
paint()
method.