HOMEWORK 1: Getting Acquainted with Java Swing
This is an INDIVIDUAL assignment.
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.
During the course of this semester, we will be creating an interactive
"photo album" application. When completed, the application will allow
you to view photos, annotate them, and organize 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
Your application must behave reasonably when resized, moved, etc. "Reasonably" means that the window should be resizable, but that panels that the various components should have minimum sizes so that control panels cannot be shrunk in a way that clips their contents. Likewise, enlarging the window should make the content size larger but not expand control panels unnecessarily. (Look at the way that most "standard" desktop apps behave when resizing, and ask if you have any questions.)
- A menu bar with the following menus:
- Import. Selecting this menu item should pop up a JFileChooser dialog box (see
here for details). Eventually (in future assignments), this will allow allows the user to select a new photo to import it, or select a folder to import all the photos in that folder, but for now the dialog box can do nothing, meaning that selecting either Open or Cancel should just dismiss it.
- Delete. Eventually this will delete any selected photos.
- Exit. This should quit the application.
- View: This menu should contain three radio-style buttons (see JRadioButtonMenuItem) that lets the user select
between three "view modes". These view modes should be mutually exclusive, meaning that when one is selected the
others are de-selected.
- Photo Viewer. This should be the default selection. Eventually this will change the view mode to show a single photo.
- Browser. Eventually this will change the view mode to show a grid of small "thumbnail" images of the imported phtos.
- Split Mode. Eventually this mode will show a single photo, with a "film strip" one-dimensional view of the imported photos below it.
- 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 serve as a status bar, and be used to
display various 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:
- A collection of toggle buttons (JToggleButton, but read on for more details), (at least 4, that we'll use to
tag the current photo eventually. You can come up with your own
tags for these, such as
"Vacation," "Family," "School," "Work," etc). Note that
the behavior I'm after here is that you should be able to "tag"
photos 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, which will eventually move through the imported photos
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).
See here for instructions on how to submit your homework. These instructions will be the same for each assignment.