Getting acquainted with Swing

Lab 1: Getting acquainted with Swing

Step 0: Finish signing up for the class

  1. Connect to the class Moodle to self-enroll.

Objective

The goal of this assignment is to (re-)familiarize yourself with the Java Swing environment to create a GUI application. This should not be a difficult assignment; its purpose is to get you up to speed with Swing. Moreover, all subsequent labs will build on this first assignment, so it’s important to do this one right.

Note: You should avoid using any interface builder tools for this project. Such tools can be a very useful component of your developer’s toolbox, but the goal of this and the subsequent assignments is to master what is going on underneath the hood.

Description

In these lab assignments and during your homework time, you will be creating an interactive photo browser, or Photothèque. The final version should allow the user to view, annotate, and organize a collection of photos.

In this first lab, we will create the basic skeleton of the application. Here, we will just be using the existing components provided by Swing. Later, we’ll extend the application with our own custom components.

You will probably find it useful to refer to the Java APIs when doing this assignment.

Assignment

  • Create a skeleton application that:
    • Shows a new window (JFrame) when launched
    • Presents a menubar:
      • File
        • Import – should open a JFileChooser but do nothing with the choice for now
        • Delete – will eventually delete a photo.
        • Quit – exit the application
      • View – Contains a radio button for the view options
        • Photo viewer (default) – show one photo at a time
        • Browser – will eventually show a grid of thumbnails
    • Main portion of the window. An empty JPanel for now.
    • A JLabel at the bottom of the window to act as a status bar.
    • A toolbar at the left or top of the window. Include a JToggleButton to choose between different categories of photos (e.g. “People,” “Places,” “School”, etc.)
    • The window should handle resizing correctly.
    • All unimplemented functionality should, for now, just display a placeholder message to the status bar.

Your application must behave appropriately when resized, moved, etc. Think about how the individual components resize to make sure they react reasonably for small or large windows. Think about minimum and maximum sizes.

There is also some flexibility in the design of your application. For example, you may use a different component than a JToggleButton if you think of a better interaction.

Deliverable

We’ll continue working on this assignment throughout the semester. To submit your skeleton, first export your project from Eclipse (File → Export… → General → Archive File). Then submit the generated archive using the class Moodle.

Grading

To receive full credit, your submission should build and run on my machine and should implement all of the basic functionality described above. But that will only get you half way there. The other half of your grade depends on how you organize your code and on the quality of the code you write.


This assignment is based on one by Keith Edwards.