import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.effect.DropShadow;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;

/**
 * Draws a checkerboard.
 *
 * @author Drue Coles
 */
public class CheckerBoard extends Application {

    @Override
    public void start(Stage stage) {

        Pane root = new Pane();
        
        final int n = 8; // number of squares in each row and column
        final int k = 75; // length of each square  in pixels
        final int gap = 25; // padding around the board   
        final int size = 2 * gap + n * k; // size of scene
        Scene scene = new Scene(root, size, size, Color.WHITE);

        // Draw a completely black board (red squares will be added later).
        Rectangle board = new Rectangle(gap, gap, n * k, n * k);
        board.setFill(Color.BLACK);
        root.getChildren().add(board);

        // Add a drop shadow to the board.
        DropShadow dropShadow = new DropShadow();
        dropShadow.setOffsetY(12);
        dropShadow.setOffsetX(12);
        dropShadow.setColor(new Color(0.3, 0.3, 0.3, 1));
        board.setEffect(dropShadow);

        for (int row = 0; row < n; row++) {
            for (int col = 0; col < n; col++) {

                // Fill in the red squares.
                if (row % 2 == col % 2) {
                    int x = gap + col * k;
                    int y = gap + row * k;
                    Rectangle rect = new Rectangle(x, y, k, k);
                    rect.setFill(Color.FIREBRICK);
                    root.getChildren().add(rect);
                }
            }
        }

        stage.setTitle("Checkerboard");
        stage.setScene(scene);
        stage.setAlwaysOnTop(true);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}