/* This program receives the number of rows and columns from the user and
 * prints a checker board.
 * 
 * Adam Tran
 * 9/26/08
 * 
 * This program is extended by ColorPanel.java
 * 
 */

import javax.swing.*;    
import java.awt.*;     

public class project412 {

   public static void main(String[] args){
	 JFrame theGUI = new JFrame();
	 theGUI.setTitle("Checkerboard");
	 String inputStr = JOptionPane.showInputDialog("Number of rows", "5");
	 if (inputStr == null) return;
	 int rows = Integer.parseInt(inputStr);
	 inputStr = JOptionPane.showInputDialog("Number of columns", "5");
	 if (inputStr == null) return;
	 int cols = Integer.parseInt(inputStr);
	 theGUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	 Container pane = theGUI.getContentPane();
	 pane.setLayout(new GridLayout(rows, cols));
	 for (int i = 1; i <= rows * cols; i++){ // For each panel, row * cols
		 int color = 255; // White by default
		 if (i % 2 == 0){ // Every other, determined by the remainder
			 color = 0; // Set to black
		 }
		 Color backColor = new Color(color, color, color);
		 ColorPanel panel = new ColorPanel(backColor, 50, 50);
		 pane.add(panel);
	 }
	     theGUI.pack();
	     theGUI.setVisible(true);
   }
}