Lab Assignment 1 -- Demo and Writeup Due 6 p.m. Sept. 18 in the lab session
CS 5551, Fall Semester, 2006
10 Points
Topics: Introduction to Java interfaces

Reference: Chapter 2 of the Swing Tutorial book

The assignment: Make an enhanced version of the "Hello World" program with a "Quit" button in addition to the "Hello World" label. I think this can be most easily done by modifying the SwingApplication code for Example 2 of Chapter 2. It can be downloaded from:
SwingApplication.java:
The interface should look something like this:

-----------------
|               |
|  Hello World! |
|               |
|   ---------   |
|   | Quit  |   |
|   ---------   |
|               |
-----------------

Modification 1 -- Using HTML tags:
Make the color of the "Hello World!" text red using HTML tags. Hint: see program Example 2 starting on page 22 (which is a bit more complicated than what you need).

Modification 2 -- Order of the components:
Change the order of the components so that the label (containing "Hello World!") is on top and the Quit button is below it.

Modification 3 -- Making the Quit button work:
This can be done by replacing the body of the actionPerformed() function by System.exit(0);

Modification 4 -- Making the Quit button work better:
Change the mnemonic to Q, so that pressing Alt-Q (i.e. holding down the Alt key and pressing the q-key) also exits the program. Hint: this is a minor change to the call to the setMnemonic() function.

Extra Challenge -- Switching the text colors:
It makes more sense to have the "Quit" text red in the Quit button and having the label "Hello World!" remain black. But if you use HTML to change the color of "Quit", Java can't "see" the Q to underline it (which is the convention for mnemonics). However, pressing Alt-Q will still work, so one way of fixing things is to use HTML to also underline the letter Q (easy if you know HTML).

What to turn in: Turn in the following items from the Computer Science Lab Report Format:
1. (1 point) The Basic Information (your name, class, section, TA's name, assignment number, and date) can be on a separate cover sheet or as (highlighted) comments at the top of your main program file.
11. (4 points) Include the program listing. This listing should show good style, be appropriately commented, have the important parts highlighted, and include handwritten explanations if it helps the reader's understanding of the code.
13. (5 points) The most important part. Do demos of your modified program for the TA that demonstrate that the program works correctly.


Page URL: http://www.d.umn.edu /~ddunham/cs5551f06/assignments/lab1/assignment.html
Page Author: Doug Dunham
Last Modified: Wednesday, 06-Sep-2006 10:03:20 CDT
Comments to: ddunham@d.umn.edu