CS 112 Lab 1
Swing GUI fun
Due Monday, Feb. 11th 2008

For your first lab, you will create a Java program that plays around with the swing GUI library.

Your program should create a window with 6 buttons:
Screenshot

Your program should consist of a class subclassed off of JPanel, and a main class (that is, a class in a different file, containing a main program)

Setting the Background

The background of a panel can be set with the method:

       setBackground(Color c);

Where c is a variable of type Color.  If you want to use one of the "standard" colors, you can use one of the static colors defined in the color class, like:

     setBackground(Color.red);

However, if you want to set the background to an arbitrary RBG (red/blue/green) value, you will need to create a Color with the specified values, which can be done with a call to the Color constructor:

     int red, blue. green
     
     Color c = new Color(red, blue, green);

where red, blue, and green are integers in the range 0..255.  So, we could set the background to a nice purple color by:

     setBackground(new Color(140, 0 180));

Grading

You will be graded on several criteria:

Program decomposition:  10

Try to reuse code as much as possible (for instance, you should have only one ActionListener, with clever use of parameters to the constructor, instead of 6 ActionListeners)

Coding standards 15

Be sure to do proper indentation & commenting

See the Coding Standards for more information

Working

Program compiles and puts up a window:  20
Contains all required buttons: 20
Buttons correctly modify background color: 30
Color values capped at 0..255: 5

Submission

All file(s) required for your project should be in the folder https://www.cs.usfca.edu/svn/<username>/cs112/Lab2/