-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheckerBoard.java
More file actions
58 lines (51 loc) · 1.22 KB
/
CheckerBoard.java
File metadata and controls
58 lines (51 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import javax.swing.JFrame;
import javax.swing.JFrame;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.Shape;
import java.awt.color.*;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class checkerBoard {
//fields- creating frame variables
public static int rows = 8;
public static int columns = 8;
public static Color cl1 = Color.BLACK;
public static Color cl2 = Color.WHITE;
public checkerBoard(){
JFrame checkerBoard = new JFrame();
checkerBoard.setSize(800,800);
checkerBoard.setTitle("Single checkerBoard GAME");
Container pane = checkerBoard.getContentPane();
pane.setLayout(new GridLayout(rows, columns));
Color temp;
for (int i = 0; i < rows; i++){
if (i%2 == 0){
temp = cl1;
}
else{
temp = cl2;
}
for (int j = 0; j < columns; j++){
JPanel panel = new JPanel();
panel.setBackground(temp);
if (temp.equals(cl1)){
temp = cl2;
}
else{
temp = cl1;
}
pane.add(panel);
}
}
checkerBoard.setVisible(true);
}
public static void main(String[] args) {
new checkerBoard();
}
}