|
Comp201: Principles of Object-Oriented Programming I
|
In this lab we will create Graphical User Interface ("GUI") "Shape Calculator" program which will instantiate any shape we desire with the desired, appropriate dimensions, draw it on the screen and calculate the area of that shape. Hopefully through this process we will learn a number of techniques and concepts:
This lab,in all its parts, comprises the homework assignment for this week. You are to start the work during lab and continue it on your own to be handed in next week.
To see where we are going, download and run the demo (executable jar file--select "Open" when downloading): ShapeCalc.jar
Note that it is an Honor Code violation to attempt to decompile the demo.There are 3 shape factories available in the demo: shapecalc.shapes.SquareFactory, shapecalc.shapes.CircleFactory and shapecalc.shapes.NullFactory
Since this lab consists of several parts, where the code evolves from one part to another, you need to make several lab sub-directories:
- Create an overall lab directory, lab09.
- Create 4 subdirectories under lab09, called part1, part2, part3, and part4 respectively.
Each subdirectory should contain the entire code that completes that section of the lab. Thus when you complete one part, simply copy everything, packages and all, to the next part.
When you have finished the lab, zip up the entire lab09 directory and submit it as usual in the Upload page, under the appropriate homework assignment.
For background information on the various components that go into a Java GUI, please see the lecture notes (lecture 1, lecture 2).
This lab makes extensive use of classes in Java API, whose documentation can be found here: http://java.sun.com/j2se/1.5.0/docs/api/index.html
A nice resource is the Sun's tutorials on making GUIs with Swing: http://java.sun.com/docs/books/tutorial/uiswing/TOC.html
Warning! As you progress through the lab, the directions will deliberately get less and less detailed, as you are expected to figure more and more of the process out on your own!
The completion of this lab will constitute your HW08!
Part 1: Making a simple window frame
Part 2: Instantiating a fixed shape and displaying its area on a label.
Part 3: Painting a shape onto a panel and instantiating an arbitrary shape.
Part 4. Adding a dynamically generated dialog box to set a shape's properties
For reference, here is the UML diagram of the complete system that we will be building:
Last Revised Thursday, 03-Jun-2010 09:50:18 CDT
©2007 Stephen Wong and Dung Nguyen