Hello, any help would be great. I am trying to right the code for a checkers game. I have the board built, but I don't even know how to start to put checkers on it. Can anyone give me a good shove in the right direction? I am new to Java and, well, I am new to Java.
Here is my board code:
<code>
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;
import javax.swing.*;
public class CheckerBoard
{
public static void main (String args[])
{
int row = 8;
int col = 8;
JFrame checkerBoard = new JFrame();
checkerBoard.setSize(400,400);
checkerBoard.setTitle("CheckerBoard");
checkerBoard.setDefaultCloseOperation(JFrame.EXIT_ ON_CLOSE);
Container pane = checkerBoard.getContentPane();
pane.setLayout(new GridLayout(row,col));
Color checker;
for (int x = 1; x <=(row*col); x++)
{
int altr = 0;
altr = (x-1) % col;
altr += (x-1) / col;
if (altr % 2 == 0)
{
checker = Color.black;
}
else
{
checker = Color.red;
}
JPanel panel = new JPanel();
panel.setPreferredSize(new Dimension(400/row, 400/col));
panel.setBackground(checker);
pane.add(panel);
}
checkerBoard.setVisible(true);
}
}
</code>