CS324e - Assignment 2

Placed Online: Wednesday, September 19
Due: Thursday, October 4, no later than 11 pm
Points: 25, about 2.5% of the final grade

Individual Assignment. This is an individual assignment. You must complete the assignment on your own. You may use the examples shown in class, but you may not get help from anyone besides the instructor and TA. Copying code or getting code from anyone besides the the instructor or TA is cheating and will result in an F in the course. You can discuss approaches to the problem with others as long as you don't write code or look at code.

The purpose of the first assignment is to practice the basic GUI programming techniques as shown in class. This should be a VERY  simple assignment.

Create a series of 3 classes, PinkCirclesMain, PickCirclesFrame, and PinkCirclesPanel. PinkCirclesMain will be the public class. The other 2 classes will be included as non-public classes in the PinkCirclesMain.java file, the same as we have done in class. Refer to the sample code from this post: https://piazza.com/class#fall2012/cs324e/14 or copy the code below.

import java.awt.*;
import java.awt.gemo.*;
import java.swing.*;

public class PinkCirclesMain {
    // main method

class PinkCirclesFrame extends JFrame {
    // code for frame class

class PinkCirclesPanel extends JPanel{
    private static final int NUM_ROWS = 2;

    // code for panel class

Create a panel with an orange background that is filled with ellipses. Each Ellipse is pink with a black outline. The total number of ellipses will be equal to NUM_ROWS times NUM_ROWS. So when NUM_ROWS = 2 there will be a total of 4 ellipses arranged in 2 rows, with 2 ellipses per row. If the constant NUM_ROWS was changed to 3 there would be 9 ellipses arranged in 3 rows, with 3 ellipses per row.

Here is what your program should produce given a frame size of 450 by 450 and NUM_ROWS = 2.

Override the paintComponent method in the PinkCirclesPanel class so that if the frame is resized the ellipse resize correctly. Here is what the frame looks like after resizing the window while the program is running:

If the NUM_ROWS constant is changed to 4 your program should produce the following without making any other changes:

And here is the same program after resizing the window while the program is running:

It is okay for the outlines of circles to overlap and form a line of one pixel as shown below:

It is not okay to have gaps between circles, orange between the last circle and the frame border, or missing outlines at the frame border.

Orange between last circle and frame border (BAD):

missing outline at frame border on the  right side (BAD)

Correct solution with no missing borders. (GOOD)

Use the Ellipse2D.Double class to represent each ellipse.

You will graded on the correctness of your solution and your programming style.

When you complete the assignment turn in your PinkCirclesMain.java  file which will include all your source code, using the turnin program. This page contains instructions for using turnin. Be sure you upload the file to your CS324e folder.