CSI Laboratory # 2
Due: Start of class on Thursday, 9/12 for Fienup's section or Friday, 9/13 for Jacobson's sections
Objective: This lab is intended to introduce you to simple event-driven programming by making your No-Clicking sign from lab 1 responsive to actions the user performs with the mouse.
First you need to locate a free computer in either Wright 112 or 339. Once you have logged on, if you have not already changed your password, do so now! Follow the directions on the paper that contains your "User Name" and "Initial Password."
Create a new folder "lab2" on the " Student Z: " drive in the folder "cs061" which you created in lab 1.
Start Internet Explorer by Start | Programs | Internet | Internet Explorer and go to http://www.cs.uni.edu/~fienup/cs061f02/labs/lab2/.
Download each of the files "objectdraw.jar", "lab_2.gpj", and "NoClicking2.java" by right-clicking on the name of each file and selecting "Save Target As". Save these files to your newly created "Z:\cs061\lab2" folder.
Start jGrasp by double-clicking on the lab_2.gpj project file that you downloaded to your new lab2 folder. By using this project file you sets up the correct Compiler and run-time settings for the objectdraw package.
Click on the "Project" tab at the bottom of the upper-left-hand sub-window of jGrasp. Double click "NoClicking2.java" file. Enlarge the NoClicking2.java" window .
The text we have placed in "NoClicking2.java" is just the skeleton of a complete Java program. We have included the header for the definition of a class "NoClicking" that extends "WindowController" and within this class we have typed headers for the event handling methods you will want to use during lab. You will want to cut and paste your "begin" method from lab 1 that constructs the "No Clicking" sign.
You should follow our lead and begin writing your program by typing comments rather than actual Java commands. Near the top of the file we have included a temporary comment telling you to enter your name, course-section time and the current date. Such identifying comments are always good practice, and in a class like this they make the grader's job much easier.
In Lab 2 we want you to explore the mouse-event methods by having your "No Clicking" sign change with mouse actions. In particular, we want your program to:
- emphasize the sign's warning by making the word "CLICKING" bold when the user moves the mouse into the applet window. As indicated in the blue "Quick Summary of Graphic Objects and Methods" handout, there is a "setBold" method which you can use to change the style of Text objects. There is also an obvious place to tell Java to make this change -- the "onMouseEnter" method. To make this possible, you will need to make an instance variable for the name of the Text object containing the word "CLICKING" and assign it a value when the Text object is constructed.
- return the word "CLICKING" to plain text when the mouse moves out of the applet window.
- have the circle and diagonal line through the text disappear while the user presses the mouse button. You can use the "hide" method to make these objects disappear.
- have the circle and diagonal line through the text reappear when the mouse is released. You can use the "show" method to make these objects re-appear.
The submission procedure is as follows and will be basically the same every week.
- Turn in a hard-copy printout of your completed NoClicking2.java program. Make sure you included your name, section, and current date in a comment at the start of the program.
- Turn in a 3.5" floppy disk containing the files: NoClicking2.java, objectdraw.jar, lab_2.gpj.
These should be turned into the instructor inside the same large vanilla envelope as last week.
Teaching Assistants Availability
- (In Wright 112 or Wright 339 as indicated)
|
M |
T |
W |
Th |
F |
9 |
Daniel - 339 |
|
Daniel - 339 |
|
Daniel - 339 |
10 |
Daniel - 339 |
|
Daniel - 339 |
|
Daniel - 339 |
11 |
Daniel - 339 |
|
Daniel - 339 |
|
Daniel - 339 |
12 |
PJ - 339 |
PJ - 339 |
PJ - 339 |
PJ - 339 |
|
1 |
PJ - 339 |
PJ - 339 |
PJ - 339 |
PJ - 339 |
Daniel - 339 |
2 |
Daniel - 339 |
|
|
|
|
3 |
Daniel - 339 |
PJ - 112
(3:30 PM) |
Daniel - 339 |
PJ - 112
(3:30 PM) |
|
4 |
Daniel - 339 |
PJ - 112 |
Daniel - 339 |
PJ - 112 |
|
5 |
|
PJ - 112 |
|
PJ - 112 |
|
6 |
|
PJ - 112 |
|
PJ - 112 |
|