Your task is to draw a simple checkerboard pattern.

Here is a sample program output:

.

Complete the following file:

CheckerBoardComponent.java

import javax.swing.JComponent; import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Rectangle; public class CheckerBoardComponent extends JComponent { public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; // your work here . . . } }

Use the following file:

CheckerBoardViewer.java

import javax.swing.*;

/**
   Shows a frame with a checkerboard
*/
public class CheckerBoardViewer
{
   public static void main(String[] args)
   {
      JFrame frame = new JFrame();
      frame.setSize(300, 400);
      frame.setTitle("CheckerBoardViewer");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      CheckerBoardComponent component = new CheckerBoardComponent();
      frame.add(component);
      frame.setVisible(true);
   }
}