4.9 Homework Assignment 4 - Applets
Due date and time: October 13, 2005 at 11:59:59am (noon)
This homework assignment is intended as an exercise for working with existing Data Structures, Applets, Layout Managers, and GUI components. Since we have not yet discussed Event Handlers, you will merely build the Graphical User Interfaces in Applets without the underlying functionality.
For this homework, the guidelines are set forth below; however, specifics on where to place GUI components is left to you. Part of the duties of a developer is to make decisions on how users interact with the User Interface. For this assignment, lay out the user interface according to your best guess on what is most effective.
4.9.1 Part 1 - Kaleidoscope
In a previous homework, you have implemented the data structure for the geometric objects of a Kaleidoscope. These objects included Shapes of type Rectangle, Ellipse, Triangle, Square, and Circle.
In this part of the assignment, you will build the bare-bone GUI interface, which will later be used to show the randomly generated shapes in a Kaleidoscope-like layout (mirrors, diagonal partitions, etc.)
Your interface must address the following items:
- The largest part of the screen should be used for the painted Kaleidoscope. For now, substitute this area with a blank Panel. (Hint: BorderLayout)
- A menu of options exists to selectively turn on/off the 5 geometric shapes used for drawing. (Hint: checkboxes). Make sure that the checkboxes are labeled with the geometric shape names.
- A button will dictate whether to start or stop the drawing of geometric objects. This button will change labels between Start and Stop. For now, use a button with text "Start".
- Place all of the menu items in some logical layout (up to you what LayoutManager you use for the components)
You will need to assign some size to this applet, e.g. a width of 800 and a height of 600. Name the Applet class
HW4Part1.java. When loaded with appletviewer, the Applet should show a blank Panel for the future drawing of shapes, and an area with GUI components as outlined above. The order or layout of these components is up to you.
4.9.2 Part 2 - Employee Database Changes
In the last homework, you developed the data structure and manager class for an employee database. You used an array to store the employees. In this part, you should revisit that code and change it to use a hashtable instead of an array. That is, all employees (implementing interface Payable) are now stored in a hashtable.
Recall that an array holds a number of elements in some linear data structure, and items appear in some index position x. In a hashtable, there exist keys and values. You should use the employee names as keys, and the employee objects (implementing Payable) as values. Once the array has been changed to a hashtable, you will also need to change the parts of your code in which you search for an existing employee. Using a hashtable should make this task much easier, and you are required to change your existing code to leverage the benefits of looking up keys in hashtables. Look over the lecture discussing hashtables, and you will find useful methods for this purpose.
The names of classes remains the same as in the previous homework assignment.
4.9.3 Part 3 - Employee Database Form
You will now build a non-functional Form (GUI) which replaces the need for instantiating employees in code. This interactive interface could be used to manage a database of employees.
The following functionality must be present in your GUI:
- An interface for Adding employees.
The following fields must be considered:
- Type of employee: Professor, SupportStaff, Student. Use a Choice component to allow the user to select one of these types.
- Name of employee: Use a TextField
Depending on which employee is selected in the Choice, one area for employee-specific information is made visible. While you do not need to implement this functionality at this time, you should lay out the 3 groups of additional options for the 3 types:
- GUI component for Department Name
- GUI component for Tenure or Not Tenure (Hint: What GUI component best encodes a boolean value?)
- GUI component for Name of Support Area
- GUI component for Unionized or Not Unionized
- GUI component for School Name
- GUI component for Major Name
- GUI component for Year
All of these field must be included in your interface. In the next assignment, you will be able to add functionality to these components to enable and disable visibility selectively. Once the functionality has been added, some of the clutter will be removed.
You should include a Button to "Add" the current form data (filled out by the user) to the database. Again, you will not add the functionality at this time, but only the GUI components.
Finally, you should also include a staus bar, which will contain error messages. Hint: Add this status bar as a simple Label.
- An interface for selecting an employee, assigning hours worked and pay rate, and printing some information in the GUI:
The following fields must be considered:
- A List component for selecting the employee.
- A TextField to enter the Hours Worked.
- A TextField to enter the Pay Rate.
- A Button to "Add" the above two items to the selected employee. Remember, just filling out the form does not enter the data into the database. A Button must be used to perform that action.
- A TextArea that will print information about the employee.
None of the GUI components must be functional, but make sure to lay them out correctly in your applet.
All fields that are not self explanatory must be labeled accordingly with the Label component. For example, an entry TextField for PayRate must be labeled so, otherwise the user has no idea about what to enter.
Using the topics discussed in class, you should be able to build a well laid out GUI. I suggest starting Part 1 and 3 on paper, and then implementing the GUI layouts in a top-down fashion, i.e. the largest partitions first.
Select some reasonable size for your applet, and name the class
4.9.4 Submission instructions
Use the submit script to submit your assignment (instructions on class web site). For Parts 1 and 3, also submit HTML files, which can be used with
to view your Java applets.