This lab will give you more practice with your applet skills.
Download the jar file Face.jar
to your csci/201 directory and then unjar the file
(Help). Create a new
and mount the Face directory that was extracted
from the jar file in the step above (Help).
Click on the icon for the Face.java file. This should
bring up the source code for the
Go ahead and try to compile and run the program.
Bet that didn't work. The problem is that NetBeans assumes that
new projects are applications, not applets.
You need to change the executor.
Go into the Filesystems pane of the
Explorer panel and right-click on
Next select Properties from the pop-up window.
This will bring up a Properties of Face window.
Now select the Execution tab at the
bottom of the Properties window.
Most likely the Executor is set to
Click on the words External Execution.
This brings up a menu from which you must choose
Execute your applet after setting you have set Face.java
for applet execution.
You should see a rather abstract face with only a nose and mouth.
Now look at the
Face applet that generates this program.
If you need a refresher on applets, view the Applets lab.
Show your instructor that you have run the
and have set up your project correctly.
You need to modify the
paint() method of the
Face class to produce an improved face. (Ah,
if all of life were so easy.) You are expected to be creative, both
in designing the face and in using Java classes. Look at Sun's
documentation for the Color
classes to see what colors and graphic objects are available. You
might also find your textbook to be useful.
Take a look at Sun's on-line documentation for the fillArc method of Graphics. Everything we needed to know to draw that nose is located in this information. You just have to read and understand it. So give it a try! (By the way, reading and understanding documentation is a major part of the work life of a computer professional.)
In order to use the methods defined in the Graphics class, 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 (not up) the right side of the display. Also, distances are measured in terms of pixels, the little dots that make up your screen.
Remember, the order in which the objects are drawn to the screen makes a difference. If you want to draw a black pupil in the center of a green iris, you must draw the surrounding iris first.
Here are some of the faces that students have created in the past when CSCI 201 was taught using C++. Most of these folks actually graduated from UNCA in spite of this assignment.
This lab has more flexible rules than the others. However, it has few definite rules:
Obviously, you want to show the world your creation. You can do this by FTP'ing your compiled Java code and your HTML file to your UNCA web page on bulldog. This requires a few steps, but we're certain you're up to the challenge. Just go back to a terminal screen and type the following commands:
[csciuser@mach dir] cd ~/csci/201/Face [csciuser@mach dir] ftp bulldog.unca.edu Trying 220.127.116.11... Connected to bulldog.unca.edu (18.104.22.168). 220 bulldog.unca.edu FTP server (Compaq Tru64 UNIX Version 5.60) ready. Name (bulldog.unca.edu:csciuser): bulluser 331 Password required for bulluser. Password: type your bulldog password here, it will not be echoed 230 User bulluser logged in. Remote system type is UNIX. Using binary mode to transfer files. ftp> cd public_html 250 CWD command successful. ftp> put Face.class local: Face.class remote: Face.class 227 Entering Passive Mode (152,18,64,9,NN,NN) 150 Opening BINARY mode data connection for Face.class (152.18.69.NN,NNNN). 226 Transfer complete. NNN bytes sent in XXX secs (XXX Kbytes/sec) ftp> put Face.html local: Face.html remote: Face.html 227 Entering Passive Mode (152,18,64,9,NN,NN) 150 Opening BINARY mode data connection for Face.html (152.18.69.NN,NNNN). 226 Transfer complete. 196 bytes sent in XXX secs (XXX Kbytes/sec) ftp>quit 221 Goodbye.
Remember, you type the words in maroon. Since you are transfering into your bulldog account, you must use your bulldog password and user id (in place of "bulluser"). Once you've done the file transfer, go to your web browser and try to load the URL http://bulldog.unca.edu/~bulluser/Face.html. If this results in the display of the message "You are not authorized to view this page", you need to log into bulldog.unca.edu and run the command openhomepage. A bit more information about this procedure is explained in the CSCI 107 -- Introduction to HTML lab description.
Show your Face to your lab instructor. The one you designed in the Java, that is.