HOMEWORK 1: Getting Acquainted with Java Swing
This is an INDIVIDUAL assignment.
Objective
In this homework assignment, we want you to become familiar with the basics
of using Java Swing to create a GUI interface. Unlike in future assignments,
where you'll be extending Swing to do new things, here you'll only be
assembling already-provided Swing components to create a user interface.
Future assignments will build on this first assignment, so it's important
for you to get this one right and to understand what you have done.
Description
During the course of this semester, we will be creating an interactive
"digital notebook" application. When completed, the application will allow
you to take notes (either through typing or with hand-drawn notes), and
organize and view them in a variety of ways.
In this homework, we'll create the basic "shell" of the application. The
goal of this homework is to simply give you some practice writing basic
Swing GUIs (using existing components instead of creating your own), and
to make sure that your environment is set up correctly.
Your application must create a new window (a JFrame component) when it starts.
The components and behaviors that your application must provide in this
window are:
- A menu bar with the following menus:
- File:
- New Page (creates a new notebook page, eventually)
- Delete Page (deletes the current page, eventually)
- Exit (quits the application)
- View:
- Show/Hide Page Sorter. Initially, the menu item should be labeled
"Show Page Sorter". Selecting it should display a second
JFrame, the contents of which can be empty for now (for example,
a JPanel with size set to 300x400 or something). This second
frame must have a working Close box on it that dismisses the
frame. While the
second frame is displayed, the menu should be labeled
"Hide Page Sorter" and selecting it should make the second
frame disappear. If the frame is made invisible (whether
through the menu or clicking on the Close box on the frame),
the menu should change back to "Show Page Sorter."
- In the main portion of the window should be your content area. For
now (since we haven't written the content area component yet), this
can simply be a blank JPanel set to have a reasonable size.
- Along the bottom of the frame should be a label that will be used to
display status messages.
- Along the left side of the frame will be a collection of tools that
will (eventually) operate on the content. These tools should include:
- Graphical radio buttons (JRadioButton) labeled Text and Pen
- A collection of toggle buttons (JToggleButton, but read on for more details), (at least 4, that we'll use to
flag the type of notes in the content area eventually. These should include at least
"Appointment" and "Action Item", and several others of your
choosing (for example, "CS4470" or "Personal Stuff"). Note that
the behavior I'm after here is that you should be able to "tag"
pages with zero or more of these flags. So, it's fine with me
if you want to use a different type of component that gives a
similar behavior but looks better (check boxes for instance).
- Page forward and backward controls; these will move to the next and previous page in your notebook, respectively, once the application supports multiple pages.
Your application must behave reasonably when resized, moved, etc.
For all of the controls, selecting them should display a message in the
status label describing what control was just activated.
This should not be a hard assignment. Again, the main goal is to ensure
that you understand how to structure a basic Swing application, how
to write callbacks, and how to respond to events such as windows appearing
and disappearing (to change menu labels, for instance).
Deliverable
This is an INDIVIDUAL assignment; while you may ask others for help on Java
or Swing details, pleaes build your application on your own.
Here are the details for how to turn in the assignment. We'll be following this structure for all of the turn-ins:
0. Make sure your program is runnable from the command line using the command "java NotebookApp" when run from inside your project directory (described below). Use exactly this name (with no package) to make things easier on me and the TAs.
1. Create a new directory using your last name as the name of the directory.
2. Compile your application and place both the sources and classfiles into this directory (they can be at the top-level or in a subdirectory, whatever you want).
3. Put a README.txt file into the top level of the directory. This file should contain your name and email address, the version of Java you used (1.5.x or 1.6.x, please) as well as any special info we migiht need in order to run your code.
4. ZIP this directory and submit via T-Square (instructions are here).
Please take care to remove any platform dependencies, such as hardcoded Windows
path names or depencence on a particular look-and-feel that may not exist on
all platforms. Also, if you use any images in your application, please make sure that you include these in your ZIP file and that your code will refer to them
and load them properly when from inside the directory that's created when
I unZIP your code.
Grading for this assignment, and future assignments, will roughly follow
this breakdown:
- 60% functionality
- 40% good architectural design, coding style, commenting
Please let the TA or me know if you have any questions.