Computer Science 1
Top Lectures Assignments Noticeboard

Assignment 5

Due: 27 April 2000, beginning of class. STAPLED!

Image Display Tool (100 points)

This program will allow you to display and manipulate images (i.e., jpg and gif files). To understand what your program will do,

  1. Download the following files:
    1. IPlayer.class
    2. ImageGUI.java
    3. ImageLabel.java
    4. pics.txt
  2. Compile the Java source files.
  3. Execute the command
    java IPlayer
  4. In the filename field, enter the file name pics.txt and then press the process button. This will create two button widgets, one labeled Duke and one labeled Yanks. (Note - you may need to resize your GUI to see the buttons.)
  5. Press the Duke button. This will fill in the name in the current image field. Alternatively, you can enter the name Duke in the current image field.
  6. Press any the DISPLAY button. This will pop up a new GUI with an image. To close the image, press the CLOSE button.
  7. Try the BW and FLIP buttons.
  8. Press the Yanks button now. Again, try the DISPLAY, BW and FLIP buttons.

In this assignment, you will need to write a class called ImagePlayer, which is a GUI that should work similarly to the IPlayer program that you executed above. We have provided a skeleton in ImagePlayer.java. Before explaining how you should proceed, we first need to understand some of the files you downloaded:

What your GUI needs to do:

  1. Create a GUI with a layout similar to the GUI we have provided.
  2. When the PROCESS button is pressed, the file containing the image names and URLS is read in to a Vector of ImageLabel objects. Recall that an ImageLabel object is created using an image name and URL.
  3. Using this Vector, create the Button widgets labeled with the image names and add these widgets to your GUI.
  4. When the image name button is pressed, the image name associated with the button pressed should be displayed in the current image text field. Alternatively, a user may manually enter the image name in the current image text field.
  5. When a user clicks either the DISPLAY, BW or FLIP button, the appropriate image, i.e., the one with the current image name, should be shown. If the image name is invalid, an error message should be displayed in the message text field. What this means is that you will need to search the Vector of ImageLabel objects for the given image name.
  6. If the user enters a new file name and presses PROCESS again, the old image name buttons should be removed from the GUI before displaying the new image name buttons.

Some methods you might need: