Window Pain:

Here is another way to make a Panel allowing for different colored backgrounds:

pain code

Make a driver file that uses Panel02Simple above to create 4 different frames with panels inside them to look like this. Notice that each panel is a different color.

The driver file will create multiple frames of different colors by passing a parameter to the constructor of each panel like this:

JFrame frame = new JFrame("pain 1");
frame.setSize(200, 200);
frame.setLocation(200, 100);
frame.setContentPane(new Panel02Simple(Color.RED));

Copy and paste that 3 more times, change the size, location and color of each pane.