CISC370-010 Project 4
Assigned: June 27, 2001; Due: July 9, 2001
Displaying our Animals in a GUI
This project counts for 10% of the overall grade
Summary
In this project, we will continue to work with streams and files using the
animal database from project 3. However, in this project we will have a
Graphical User Interface (GUI) instead of a text based one.
Objective
The main objective of this project is to learn how to do GUI programming in
Java using swing classes. More input checking will also be done.
The GUI!
This project involves making a GUI for the previous project (Recall the
database management program). We will still read our Animals from a file (and
save them there as well). To display the Animals, we will use a JEditorPane
(See Vol. II of the text and/or go
here)
which has capabilities to display HTML files (or Strings too). The first step
in this project is to implement a toHTML() method that is similar
to the toString from project 2, just extended to display our Animal
information in HTML (so copy your Animal classes from the previous project
to a new directory for this project). For help on HTML see links from class
web page, or others.
The next step is to actually create the GUI and all of its features. Do the
GUI by hand (do not use the Forte' suite or anything similar- we will not give
credit for such code). Use the layout manager(s) of your choice,
a combination of GridBag and Border is suggested. Your GUI should look nice
and be functional.
The exact look is up to you, as long as it implements the requirements
stated below. The JEditorPane should be set so the user cannot edit its
contents and also be enclosed in a JScrollPane (for possible horizontal and
vertical scrolling).
Here is a sample GUI:

Here is a picture of the GUI getting ready to accept input:
Here are the functions the program must do (Formally):
- Display an Animal in HTML in a JEditorPane (toHTML method)
- Ability to Cycle through the animals in the Vector. (with the Back
and Forward buttons)
- Ability to click on Hyper-Links (Web Browse) with a back button (Page
Back) to go back to old pages (Best done with a
Stack
of URL objects)
- Ability to ADD a new animal of the 4 types
- Ability to DELETE an animal from the Vector
- Ability to SAVE the current state of the database to file (not shown)
- Implement
windowClosing() to print "Warning: elements not
saved!" and then exit
- Exit and WRITE the database to a file
- Exit without saving changes to database
More on toHTML()
This method should be implemented in each class in a similar way that
toString is, except it should return a String which contains
info on the Animal in HTML (to display in the JEditerPane).
For an example string that should get returned, see
this. This method should use super
just as we did with toString(), just wth some HTML formatting
added.
Turn In:
- Put your javadoc output on your webpage (and include URL in paper turn-in)
- Send all of your source code (and sample database file with at least
one of each animal in it) as a jar file to
morecraf=cisc370@eecis.udel.edu, you will get an acknowledgement
that the project has been received automatically. (Notice the
nonstandard email address. Submissions must be to this address
before class on due date to receive full credit.)
Help with jar:
To create a jar file, simply do (in the directory that contains your project
4 work directory):
jar cf project4.jar proj4
This assumes that proj4 is the name of the directory your
project is in and that you want to put it into a project4.jar
file.
To verify that the table of contents of your jar file is correct do:
jar tvf project4.jar
An example GUI
For an example GUI, using swing with the GridBag and Border layouts, for
the ROI application from the first project go
here.
Grading
- Working GUI - 80%
- GUI closes properly (Implements
windowClosing())
toHTML() methods in all classes
- Proper use of JEditorPane
- GUI look and feel - how does it respond to being resized
- Back and forward buttons that work
- Page back feature
- Add, Delete, Save, Exit+Save and Exit features
- Exception handling for invalid input (i.e. number fields must be
numbers!)
- GUI works with database file submitted - 10%
- JavaDoc on WebPage - 10%