This lab will have you writing a graphical program that reacts when the user interacts with it. This program will be an application (stand-alone) program, that is, you will not need the DrJava Interactions pane to run the program. Also, you can decide how much of the program you would like to implement. Your choices will determine your possible maximum grade, but you do have the opportunity to earn more than 100 points on this lab assignment.
We will concentrate on the following idea that was discussed in class:
There will also be a review of the following two concepts previously covered:
Check out the Lab6 Skeleton from the repository. This skeleton is basically the same as the one for Lab 5. You need to create a package for your code inside this project. You will also need to create Java source code files and put them inside this package.
Attendance will be taken for this lab and will count towards part of this lab's grade.
You will need to design your solution using UML before you begin coding. You will also be required to submit a UML diagram named Lab6.grn
with your final submission.
Create a program that contains a drawing canvas. When the user clicks on the drawing canvas with the mouse, a shape (ellipse or rectangle) appears. You (the programmer) will select the color the shape appears in as well as what size the shape appears. Both of these can be the same for every shape that is created. The TAs will discuss this week in lab about using a mouse listener to have the drawing canvas react to mouse clicks in this manner.
The basic functionality of above is maintained, except the program allows the user to select from a set of possible color choices for the shape. There should be at least four different color choices for the shape, shown to the user in some reasonable way on the graphical interface. In the last half hour of lab this week, the TAs will go over some ideas for how to implement this type of behavior.
You will implement the basic functionality as described above as well as the advanced functionality. However, you will change the color selection mechanism so that when the user wants to select a color, they select a color from the JColorChooser component. Also, the user should be able to specify a size for the shape (both length and width). Use either two JSliders or two JSpinners to allow the user of the program to select a size for the shapes.
The Lab6.jar
must be submitted using the electronic submission command the evening before (11:59:59pm) your next lab session, the due dates are summarized in the table below. Note that your submission must include your Java source code files as well as a file that contains your UML diagram.
Recitation Normally Meets on | Assignment due on |
Tuesdays | Monday, October 20 |
Wednesdays | Tuesday, October 21 |
Thursdays | Wednesday, October 22 |
Fridays | Thursday, October 23 |
Lab authored by Adrienne Decker
Page maintained by Adrienne Decker
Contact: adrienne@cse.buffalo.edu | 130 Bell Hall | (716)645-3180 x 161