Your Task will be to to provide a GUI interface for classes Student and Store. I have created the classes Student, Date, Person and Store. But am having difficulty creteating GUI interface.
The sytem must do the following:
1. Enter a Student record using a form displayed on the
2. Save the entered record to a store;
3. Retrieve and display records from the store; each time this option is selected the next record is
displayed; when the end of the store is reached the first record is displayed;
4. Save a store to a file;
5. Retrieve a store from a file.
It should preferably display an error message. Similarly it should prevent a user from
opening a new store without saving an existing one ??" or better still ask the user to confirm the action
using a dialog.
A complete system will also allow photographs to be stored and retrieved with each record.
## Deliverables
The aim of this task is to provide a GUI interface for classes Student and? You will not need class
Academic.
Requirements
You are required to produce a system that allows a user to do the following:
1. Enter a Student record using a form displayed on the screen; note: a student record includes the
data items inherited from Person as well as those in class Student.
2. Save the entered record to a store;
3. Retrieve and display records from the store; each time this option is selected the next record is
displayed; when the end of the store is reached the first record is displayed;
4. Save a store to a file;
5. Retrieve a store from a file.
A complete system should be robust ??" e.g. if a user tries to retrieve records and none are saved it should
not crash, and should preferably display an error message. Similarly it should prevent a user from
opening a new store without saving an existing one ??" or better still ask the user to confirm the action
using a dialog.
A complete system will also allow photographs to be stored and retrieved with each record.
All classes developed for this task must be fully documented for display using the standard
Javadoc application.
The following provides a step by step guide to the assignment. You may, if you wish, tackle it in your own
way.
Step 1:- Amend Class Store
Add the following to class Store.
private int current =0;
public incrementPointer()
// pre: store is not empty
// post: increments current;
// if current is already pointing to the
// last record in the Store then reset it to 0
public Person currentRecord()
// pre: store is not empty
// post: returns the person accessed by current
// e.g. if current = 6, then the object at location 6
// will be returned
Step 2:- Design Basic Frame with Menus
Design a basic frame for your system ??" make it inherit from CloseableFrame.
You could begin with a menu bar which has two menus: File and Record
The menu items for File would be New, Save and ReadIn
The menu items for Record would be Add, Display and Clear.
Leave the event handlers until a little later.
Step 3:- Design an InputForm
Design an input form for a student's record. Note:- a student's record includes all data declared in class
Person as well as that declared in class Student.
First make a drawing of the input form you wish to use.
Then code it in the frame class you have already developed. (You will probably need to use Panels)
Step 4:- Add some variables to your Frame
Add to your frame class an instance variable of type Store.
Also add the following boolean instance variables: storeOpen, fileOpen, fileSaved.
These will be used later to allow you to prevent users from doing things that could be fatal to the
system.
Step 5:- Add Event Handlers to Your Frame
Add the following methods to your frame class.
private void createNewStore()
// pre: true
// post: if storeOpen and not fileSaved
// displays error message
// else creates Store with default max size of 100
// sets storeOpen to true
// sets fileSaved to true
private void clear()
// pre true
// post: all text fields set to default values
private void add()
// pre: true
// post: if storeOpen
// creates Student (local variable) from input form values
// adds Student to Store
// sets fileSaved to false
// else displays error message
Note: ??" one way to display error messages is to use a dedicated text field.
When you have coded the above methods you should then complete the event handlers that will call
each of the above methods.
At this point your system should be able to create a Store and to add records to it.
Step 6:- Implement the Event Handler which Displays records retrieved from the Store
Implement the following method. You may either display a record on the
input form, or on a Canvas.
private void display()
// pre: true
// post: if not storeOpen
// display error message
// else if store is empty
// display error message
// else
// retrieve current record from Store and display it
// advance pointer in store
Now implement the event handler.
Step 7:- Add File Handling Capabilities
Modify your system so that it will Save the Store to a File, and will also retrieve a Store from the file.
In your Frame class add the following
private void saveToFile()
//pre : true
// if not storeOpen || store empty
// display error message
// else if not fileSaved
// call fileOut in Store
// set fileSaved to true
private void readIn()
// pre : true
// if storeOpen and not fileSaved
// display error message
// else
retrieve Store from file
Step 8:- Add Dialogs
Modify your system so that it allows the user to select the filename to be written to/read from using a
dialog. Also add a dialog which when a user quits asks for confirmation if the current store has not been
saved.
Step 9:- Add image handling capabilities to your system
Modify your system so that it will save a photo with a student record. It should also display the photo
with the student record on the screen. Note:- this will require you to amend Person so that it has an
image field. This should be a String which contains the filename of the image. Your application will
need to allow a user to select a photo at run time using a file dialog. For example, you will need to add
the following methods to Person
public void setPhoto(String fileName)
public String getPhoto()
task Requirements
In each stage shown below, all developed classes must be marked up in the standard way for
display using Javadoc.
?
Your system must compile and execute, allow a user to input data into a form, and clear the data from
the screen.
?
In addition to the requirements in the previous stage your system must allow a user to add items to a
Store
In addition to the requirements in the previous stages your system must allow a user to retrieve items
from a Store and display them on the screen. It should also allow a user to save a Store to a file and to
retrieve a Store from a file using serialization.
?
In addition to the requirements in the previous stages your system must allow the use of file dialogs and
should display a dialog when the user attempts to quit.
In addition to the requirements in the previous stages your system should allow the user to save and
retrieve images along with text data. You will be rewarded also for any other features which are not
specified above but which sensibly improve the system.