I did not use the drawing function, I did it by inserting slices. How can I use a two-dimensional array to save the coordinates of the chess pieces and the chess pieces, and then add the effect?
过彺(눈_눈)往煕
过彺(눈_눈)往煕 2018-08-12 17:07:37
0
0
1404

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);
}
}
}

过彺(눈_눈)往煕
过彺(눈_눈)往煕

reply all(0)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template