I am trying to build a java program that allows a user to play checkers. Right now I'm having trouble creating my 24 pieces & getting them to move from place to place. I want to be able to drag them from an orange square to another orange square. If the square isn't orange, I want it the program to reject the move. How can I go about doing this? Any & all help is appreciated!
import java.awt.*;
import javax.swing.*;
@SuppressWarnings("serial")
public class Board extends JPanel{
public void paint(Graphics g){
g.setColor(new Color(234, 106,32));
g.fillRect(0, 0, 400, 400);
for(int i = 0; i <= 350; i+=100){
for(int j = 0; j <= 350; j+=100){
g.clearRect(i, j, 50, 50);
}
}
for(int i = 50; i <= 400; i+=100){
for(int j = 50; j <= 400; j+=100){
g.clearRect(i, j, 50, 50);
}
}
}
public static void main(String[] args){
JFrame frame = new JFrame();
frame.setSize(400,420);
frame.getContentPane().add(new Board());
frame.setTitle("Java Chip Checkers");
frame.setLocationRelativeTo(null);
/* frame.setBackground(new Color(234, 106, 32)); */
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}