If a directory called c:\files\Face presently exists on your computer, delete it.
Let's start by reviewing some of the things that we learned about applets in lab 04 (the Stonehedge lab):
public class < class_name > extends JApplet {
public void paint(Graphics g) {
We can give the parameter any name we choose, in the example above it
is named "g". We use methods that belong to this Graphics object to
draw things in our applet display.
If any of these concepts are not clear to you look back at lab 04 and/or look at section 2.9 (page 92) in your text.
We're going to give you a project containing an applet to start
this lab. The project is stored in a zip archive so you will have to
use PowerZip to extract it. First, download a
zipped copy of the lab06 project by right-clicking on this link, and storing the target file in the
C:\files directory.
Now, double-click on the lab06.zip icon in the C:\files
directory to run the PowerZip program. On PowerZip's menu, hit the
extract button, set the download directory to C:\files and then select
ok to create:
C:\files\Face
Start up JCreator by opening the Face folder and then double-clicking on the ".jcw" file (i.e., Face.jcw). Once the project is open in JCreator, you should be able to execute the program by selecting the Execute Project option under the Build Menu of JCreator's toolbar. Run the program and look at the display created by the applet. You should see a rather abstract face with only a nose and mouth.
public abstract void fillArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
In your text, this same method header is written as follows:
void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
Clearly, the authors omitted some of the (non-essential) information
to make it easier to read.
The method header is the first line you write when you
implement a method. For example, here is the header of the method
main():
In order to be able to use methods based on their documentation, you
need to understand the information contained in the header. Follow
the hyper-links on the example below to obtain a better understanding
of the information included in a method header.
public static void main(String [] args)
public abstract void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
Finally, in order to use the Graphics methods, you need to remember
how the display coordinate system is setup. The origin of the
coordinate system is the top-left corner of the display, with the
positive x-axis running horizontally to the right, and the positive
y-axis running vertically down the right side of the display. Also,
distances are measured in terms of pixels. For more information, see
page 41 of your text.
This lab has more indefinite goals than the previous ones. However,
it has two definite rules:
Your job is to improve the face. To provide some inspiration, here are some of the faces that students have created in the past.