-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPieces.java
123 lines (108 loc) · 3.8 KB
/
Pieces.java
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import javax.swing.*;
import java.awt.*;
import java.io.*;
/**
* The purpose of this class is to create/set the picture of each pieces on a tile/button. This is NOT where we keep
track of all of the pieces.
*/
public class Pieces
{
public void setWhiteKing(JButton _button)
{
_button.setIcon(new ImageIcon("ChessPieces/whiteKing.png"));
_button.setDisabledIcon(new ImageIcon("ChessPieces/whiteKing.png"));
}
public void setWhiteRook(JButton _button)
{
_button.setIcon(new ImageIcon("ChessPieces/whiteRook.png"));
_button.setDisabledIcon(new ImageIcon("ChessPieces/whiteRook.png"));
}
public void setWhiteBishop(JButton _button)
{
_button.setIcon(new ImageIcon("ChessPieces/whiteBishop.png"));
_button.setDisabledIcon(new ImageIcon("ChessPieces/whiteBishop.png"));
}
public void setWhiteKnight(JButton _button)
{
_button.setIcon(new ImageIcon("ChessPieces/whiteKnight.png"));
_button.setDisabledIcon(new ImageIcon("ChessPieces/whiteKnight.png"));
}
public void setWhiteQueen(JButton _button)
{
_button.setIcon(new ImageIcon("ChessPieces/whiteQueen.png"));
_button.setDisabledIcon(new ImageIcon("ChessPieces/whiteQueen.png"));
}
public void setWhitePawn(JButton _button)
{
_button.setIcon(new ImageIcon("ChessPieces/whitePawn.png"));
_button.setDisabledIcon(new ImageIcon("ChessPieces/whitePawn.png"));
}
public void setBlackKing(JButton _button)
{
_button.setIcon(new ImageIcon("ChessPieces/blackKing.png"));
_button.setDisabledIcon(new ImageIcon("ChessPieces/blackKing.png"));
}
public void setBlackRook(JButton _button)
{
_button.setIcon(new ImageIcon("ChessPieces/blackRook.png"));
_button.setDisabledIcon(new ImageIcon("ChessPieces/blackRook.png"));
}
public void setBlackBishop(JButton _button)
{
_button.setIcon(new ImageIcon("ChessPieces/blackBishop.png"));
_button.setDisabledIcon(new ImageIcon("ChessPieces/blackBishop.png"));
}
public void setBlackKnight(JButton _button)
{
_button.setIcon(new ImageIcon("ChessPieces/blackKnight.png"));
_button.setDisabledIcon(new ImageIcon("ChessPieces/blackKnight.png"));
}
public void setBlackQueen(JButton _button)
{
_button.setIcon(new ImageIcon("ChessPieces/blackQueen.png"));
_button.setDisabledIcon(new ImageIcon("ChessPieces/blackQueen.png"));
}
public void setBlackPawn(JButton _button)
{
_button.setIcon(new ImageIcon("ChessPieces/blackPawn.png"));
_button.setDisabledIcon(new ImageIcon("ChessPieces/blackPawn.png"));
}
public void setAPiece(String _piece, String _team, JButton _button)
{
if(_team.equals("white"))
{
if(_piece.equals("king"))
setWhiteKing(_button);
else if(_piece.equals("queen"))
setWhiteQueen(_button);
else if(_piece.equals("bishop"))
setWhiteBishop(_button);
else if(_piece.equals("knight"))
setWhiteKnight(_button);
else if(_piece.equals("rook"))
setWhiteRook(_button);
else if(_piece.equals("pawn"))
setWhitePawn(_button);
}
else if(_team.equals("black"))
{
if(_piece.equals("king"))
setBlackKing(_button);
else if(_piece.equals("queen"))
setBlackQueen(_button);
else if(_piece.equals("bishop"))
setBlackBishop(_button);
else if(_piece.equals("knight"))
setBlackKnight(_button);
else if(_piece.equals("rook"))
setBlackRook(_button);
else if(_piece.equals("pawn"))
setBlackPawn(_button);
}
}
public void removePiece(JButton _button)
{
_button.setIcon(null);
_button.setDisabledIcon(null);
}
}