CSI Laboratory # 1
An Introduction to Java and the objectdraw Library

Objective: To demonstrate the use of the lab computers, Java and objectdraw library
Due: Thursday (Sept. 5) for Professor Fienup's section (03) or Friday (Sept. 6) for Professor Jacobson's sections (01 and 02)

This lab is intended to introduce you to the tools with which you will be working as you learn to program in Java this semester. The tasks you complete during the lab will be:

Part

Description

A

log-on to a computer in either Wright 112 or 339 using the password given in class

B

download the necessary files for lab 1

C

complete a Java program that draws a "No Clicking" sign

A picture of your completed sign should look like:

Part A. Logging-on to a computer

First you need to locate a free computer in either Wright 112 or 339. If it is not already booted to Windows, then reboot it to Windows as follows:

  1. Select "reboot" in the "Shutdown" button of the Debian log-in window
  2. click "OK"
  3. As the computer reboots quickly select "WinNT" as the operating system
  4. Press the Ctrl, Alt, and Delete keys all at the same time to get a log-on window
  5. log on using the "Username" and "Initial Password" as received in class
  6. (The first time that you log on, consider changing your password.)

Part B. Downloading the necessary files for lab 1

Once you have logged on, you can download the necessary files for lab 1 by:

  1. Create a new folder on the 'Student Z:' drive called "cs061"
  2. Inside the new "cs061" folder create another new folder called "lab1."
  3. Start Internet Explorer by Start | Programs | Internet | Internet Explorer and go to http://www.cs.uni.edu/~fienup/cs061f02/labs/lab1/
  4. Download each of the files "objectdraw.jar", "lab1.gpj", and "NoClicking.java" by right-clicking on the name of each file and selecting "Save Target As". Save these files to your newly created "Z:\cs061\lab1" folder.

The construction of a single Java program involves the use of several files. The NoClicking.java file contains a partial program of the Java program to draw the sign. The objectdraw.jar file contains the code for the collection of graphical objects we will be using to draw our "No clicking" sign. jGRASP keeps track of all these files through yet another file, lab1.gpj, called the "project" file.

Part C: Complete a Java program that draws a "No Clicking" sign

To start the jGRASP environment, double click on the lab1.gpj file icon in your Z:\cs061\lab1 folder. After a few seconds, you should see a window something like this:

To begin editing the "NoClicking.java" file, click the "Project" tab in the middle left of the screen. Then, double-click the NoClicking.java icon to get a screen similar to:

Before we can run this program you must first compile it by:

  1. Clicking on "Compiler" in the "NoClicking.java" window (upper-right of the screen)
  2. Selecting the "Compile" item from the Compiler menu

(Alternatively, you could click on the green "+" icon at the top of the NoClicking.java window)

You will know if the program compiled successfully if the "Compiler Messages" window along the bottom of the screen contains only the "----jGRASP: operation complete" message. If your program is not syntactically correct, error message(s) will appear in this window. The compiler will high-light the command it thinks is in error with a "meaningful" description of the error. Fix the first error and re-compile until no more errors exist.

When you are successful in compiling, the program can now be executed by:

  1. Clicking on "Run" in the "NoClicking.java" window
  2. Selecting the "Run as Applet" item from the Run menu

(Alternatively, you could click on the red apple icon at the top of the NoClicking.java window)

The partial program only creates the top half of the sign. Your job is to add the commands to complete the "No clicking" sign, "signs" your masterpiece, and adds the green grass.

Once you have the program working correctly, print the finished No-Clicking sign by selecting the "Print" item from the "Applet" menu in the Applet Viewer and selecting a nearby printer. Finally, print the completed NoClicking.java program by selecting the "Native Print" item from the "Print" submenu in the "File" menu.

Submitting Your Work

Congratulations, you have written a Java program. You are encouraged to continue experimenting with it. Before you do, however, you should submit it as a completed assignment. The submission procedure is as follows and will be basically the same every week.