CS 338: Graphical User Interfaces

Assignment 1

Due Friday, January 23


This assignment asks you to build your first real user interface for a realistic program. In recent lectures, you learned about layout, event handling, and the various components that make up a user interface. In this assignment, you will combine all these skills to build a complete, albeit small, GUI application.

Problem  (10 pts)

Write a program "SongLogger" that maintains a music database. Your program should allow for the input of the following data, each with the following set of associated fields:

All fields are required except those explicitly labeled "optional" above. The program should have a JList that contains all songs in the database. (Note: There should be *one* single JList with all songs of all types.) Each row of the JList should be a text representation of a song in the format shown above (that is, the text examples in the "e.g."s above).

The program should allow three basic functions: (1) Add: the user can choose what type of song to enter, fill in the appropriate information, and add the song to the database; (2) Change: when the user selects a song in the list, its information is automatically filled into the fields; if the user edits these fields, the user can finalize the changes by pressing the Change button, and these changes are updated in the list; (3) Remove: the user can remove songs from the list by selecting the song and pressing a button.

All functionality must be implemented in a single frame/window. To allow the user to enter one of the three song types, you should use a JTabbedPane with 3 panes (Rock, Jazz, Classical) where each pane contains appropriate components for that song type. Then, adding a song will add the song currently visible in the tabbed pane, and selecting a song in the list will automatically change the JTabbedPane such that the correct song type is displayed (along with the correct information for that particular song). Note that the JList and the Add/Change/Remove buttons should be *outside* the tabbed pane (since they are universal, not specific to one song type).

For error checking, you should check that all required fields are not empty. However, you do not need to check the format of data within the fields (e.g., you don't need to make sure the time length is of a proper form). Also, you should not load any information from a file (or database) on startup or save the information upon quitting. (Granted, the program would not be terribly useful without this feature, but our focus is on on the GUI itself and implementing this additional functionality would not add much for our purposes.) Please ensure that the list is initially empty on startup of the program.

Besides getting the basic functionality correct, this assignment emphasizes three important aspects of GUI building. First, the data structures underlying the GUI should be implemented in a reasonable way taking advantage of proper object-oriented programming whenever possible -- for instance, you should maintain object-oriented classes for songs and song types that are separate from your main GUI frame class. Second, the window components should be laid out in a sensible, logical way that looks reasonable on-screen and allows for easy data entry. Third, the GUI should be robust in the sense that user actions work cleanly as they should and that illegal options (except for text-field error checking) are disabled whenever appropriate.

Your main class must be called "SongLogger" such that the program can be started by typing:

    java SongLogger


It is expected that all code written for this assignment is properly commented. Please document each function you write/modify, especially in places where you have made particular choices about data structures and/or algorithms to employ. Also, please add an identification header to every file with the following format:
     * [Your Name]
     * [Your-Email]
     * CS338:GUI, Assignment [#]


The assignment should be submitted on WebCT in a single zip or tar file.


The grading for your program will break down roughly as follows: