Project 6B: Java Image Machine, Part 2

Due: December 9


Enhance your image viewer program to include the following features:

Your program should satisfy the requirements for Project 4, as well: open an image, zoom in, zoom out, reset zoom (100%), quit. Name the class with the main method for your application JIMachine.

Here are descriptions and requirements for the new features:

Previous and Next buttons

When your program starts it should get a list of all of the JPEG files (.jpg extension) in the current directory to put into an album. When the user clicks on the Next button, the program should find the next file in the list and display the image from that file. The Previous button should work in an analogous way.

When the user opens a file, that file's directory should become the new current directory. In that case, your program should get a list of files for that new directory and use it to make a new list of file names that will be used with the Next and Previous buttons.

Thumbnail view

Add a Thumbnail button to the program's GUI. When the user presses this button, the program should show small (about 60 high and 80 wide) versions of four images, starting with the current one. If the user selects an image by double-clicking on a thumbnail image, the program leaves the thumbnail display mode and displays the selected image.

If the user presses the Next (or Previous) button while in thumbnail display mode, the program should show the next (or previous) four images in the album.

The best way to handle thumbnails is to have smaller images that don't take as much memory as full-sized images. However, some students have reported difficulty in reducing the amount of memory that an image takes in memory. Therefore, I recommend that you test your program with images that are relatively small in terms of the amount of space they take up in the file (which relates to the amount of memory they need). If/when I resolve this issue and figure out a good way to reduce the size of an image in memory, I will post more information here.


Add a Caption button that opens a dialog box with a text field. The user can type a caption into the text field, which will then be displayed with the image. Captions should be displayed with the image in full-sized display mode and in thumbnail mode. You can limit the captions to 60 characters.

The file name for each image should be displayed, regardless of whether there is a caption for that image.

Save and Open

Add Save Album and Open Album buttons to your program. If the user presses the Save button and the album has not been saved before, the program opens a file chooser dialog to let the user specify a file name and location for saving the album. If the album has been saved before, the program silently overwrites the previous file. When the user presses the Open Album button, the program opens a file chooser dialog box to allow the user to select the file that should be opened.

Use serialization to save the file. You may save thumbnail images in the file, but to keep the file a reasonable size and avoid redundancy, do not save the full-sized images in the file.

The album should open in the same display mode that it was in when saved. In other words, if the user saves the album while in thumbnail mode, it should display in thumbnail mode.

When opening an album, you can assume that there have been no changes to the image files that are present in the directory.

Extra Credit

Set up the arrow keys to move from one picture to the next. The left arrow key should do the same thing as the Previous button, and the right arrow key should do the same thing as the Next button.

Turn in

Put your source and class files into a jar file and turn the jar file in on Canvas. The class with the program's main method should be named JIMachine. Your files should not be inside a folder in the jar file, and there should not be any files other than source files, class files, and an optional README.txt file. (The files and directories that are automatically added by the jar command are okay.)

20 Opens and displays an image
15 Zooms in and out, resets zoom (100%)
20 Previous and next buttons
25 Thumbnail view
15 Double click to return to normal view
30 Captions
25 Save and open album
25 Arrow keys for next and previous Extra Credit