Java Reference
In-Depth Information
Exercises
To complete the following exercises, you will require access to a Java-aware
browser. In order to run the Swing applets, this browser will also have to have the
Java Plug-In installed. This plug-in should have been installed automatically when
you installed Java SE.
12.1 From the Internet site associated with this topic, copy the .class and .html fi les
for the AppletGreeting , SimpleGraphics , ImageTest1a and ImageTest1b
examples, along with image fi les cute kittie.gif and earth.gif . Ensuring that the
fi les are in the current folder, load up each of the HTML fi les into the applet-
viewer and your browser, in turn, observing the results.
12.2 (i) From the Internet site associated with this topic, copy the .class and .html fi les
for the ImageTest2a , ImageTest2b , FahrToCelsius and SimpleSoundApplet
examples, along with sound fi le cuckoo.wav .
(ii) Do the same for the four HTML fi les above as you did for the four HTML
fi les in exercise 12.1 (again ensuring that all fi les are in the current folder).
You should fi nd that applet ImageTest2a will not run in either the applet-
viewer or your browser
For each of the next three exercises, you should create a minimal HTML page
and test this page in both the appletviewer (while developing) and your browser (for
the fi nished product).
12.3 Create an applet with a single button that holds an image. (Use the JButton
constructor that takes an ImageIcon as its single argument.) Whenever the
button/image is pressed a single 'cuckoo' should sound.
12.4 Specifying an area of size 300 pixels × 300 pixels in your HTML fi le, create
an applet that holds an image that is positioned and scaled so that it occupies
an area 40 pixels in from each side of the applet window. In order that the
applet window can be distinguished from the Web page, change the colour of
the applet's background to any colour of your choice.
12.5
Create an applet that displays a simple drawing of a house.
Search WWH ::




Custom Search