public void paint(Graphics g) {
//The loop is horizontal
for(int i=0;i<=19;i) {
//The loop is vertical
for(int j=0;j<=19;j ) {
//Equal to 1 to judge the coordinates of the black chess piece
if(chess[i][j]==1) {
//Calculate all the coordinates of the horizontal axis on the chessboard
int tempX=i*35 50;
//Calculate all the coordinates of the vertical axis on the chessboard
int tempY=j*35 40;
/ /Add black chess piece
label.setIcon(black);
//Add the coordinate position of the chess piece
label.setBounds(tempX,tempY,32,32);
//Insert the background chessboard
lbl[0].add(label);
//Refresh the background
lbl[0].repaint();
}
//Equal to 2 to determine the coordinates of the white chess piece
if(chess[i][j]==2) {
//Calculate all the coordinates on the horizontal axis of the chessboard
int tempX=i*35 50;
//Calculate the position of the vertical axis on the chessboard All coordinates on
int tempY=j*35 40;
//Add white chess
label.setIcon(white);
//Coordinates and size of white chess
label.setBounds (tempX,tempY,32,32);
//Insert the background image
lbl[0].add(label);
}
}
}