Lab 7: Graphics and Applets
- Review the example graphics files mentioned in
Lecture 8.
- Create an empty directory named
javalab7/
in
your directory.
- Create an HTML file named bargraph.html in your folder.
- Copy HelloWorld.html to bargraph.html and change appropriately:
- Change the title to Bar Graph Applet by Your Name.
- Change the applet tag to use your applet code.
- Change the width to 400, height 300.
- In the applet tag, add parameter lines for each of the following:
- three labels, label1, label2 and label3. Provide any three strings for
the label values.
- three values, value1, value2 and value3. Provide any three integers
between 0 and 200.
- Create an applet named BarGraphApplet.java in your folder.
- Copy HelloWorldApplet.java to BarGraphApplet.java.
- Change the class name to BarGraphApplet.
- Read the six parameters using the getParameter() function for each.
- The labels should be strings. Cast the values to integers.
- Paint three label strings at x=10 and y positions 50, 150 and 250.
- Paint three filled rectangles to represent the three values.
- Use three different colors e.g. cyan, magenta and yellow.
- The x positions should be 200. The y positions should be 0, 100 and
200.
- Use the values as the widths. The heights should be 100.
- Paint strings for the three values at x=210 and the same y positions.
- Return the foreground color to black first.
- Compile the applet by typing
javac BarGraphApplet.java
.
- Open bargraph.html to test and debug the applet.
- Compress the folder using the Ark archiving program to
produce
javalab7.zip
.
- Send the
javalab7.zip
file to gvogl@umu.ac.ug as an
attachment in a message with subject java lab 7.