This lab exercise will lead you through the basics of implementing and running a simple graphical applet stored within your AFS volume using Eclipse. This lab will also use a class located in an external jar file.
http://www.cs.uwm.edu/account/requestAcct.phpto obtain your username and password.
The Windows way. There should be a small lock icon in the system tray on the bottom right of the screen. If there is red cross on the icon, double click on it and renew your credentials using the dialog which will pop up. If there is no red cross, you are alreday authenticated with AFS.
The Unix way. There is script that will do this for you as well as set up a bash shell. To use the script enter the command
source /home/cae3/adobkin/cs351.shat the termnial. Alternatively, you may login to afs using the command
/usr/afsws/bin/klog pantheridwhere pantherid is your panther ID. You can change your AFS password using the /usr/afsws/bin/kpasswd command.
/afs/cs.uwm.edu/users/classes/cs351/80X/pantherid/lab/1where X is the lab section (1, 2, or 3) that you are in. This is a Unix path. If you are using Windows, you should use \\afs\ in all your paths instead of /afs/. In addition, you should use \ as the path separator instead of /.
/afs/cs.uwm.edu/users/classes/cs351/src/lab1and press the tab key.
All .SKEL files should be renamed to remove the .SKEL part. These files have parts of the code deleted. Your job is to complete the missing parts with your own code.
/afs/cs.uwm.edu/users/classes/cs351/src/lab1/lab1.jar
Eclipse can help you with hashCode() and equals(). Open SmileyFace.java and right click within the text editor. Select Source > Generate hashCode() and equals().... Select both color and diameter and click OK. Inspect the changes to SmileyFace.java.
The SmileyFace.paint() method should draw a smiley face using the given graphics context centered at the given
and
coordinates.
Remember that you must set the color first using Graphics.setColor() before drawing anything.
Methods you may find useful for drawing include Graphics.fillRect() and Graphics.fillOval().
There are corresponding methods Graphics.drawRect() and Graphics.drawOval() that just draw an outline.
Remember that for these methods
and
coordinates specify the upper left corner and not the center.
The coordinate (0, 0) is located at the upper left corner of the window.
The
coordinate increases as you go from left to right.
The
coordinate increases as you go down.
Finish the implementation of the paint method in the SmileyFaceApplet class. Draw a white background with the current size of the window, and then use the paint() method of a SmileyFace to draw a smiley face. Save the file and ensure that no errors are present. Build and run the project by selecting Run > Run As > Java Applet. You should see a white background with something moving around.
See your TA to receive credit for this lab.