package sample;
import javax.swing.;
import java.awt.;
public class MyJPanel extends JPanel{
//初始化chessState 为15*15的二维数组
public int[][]chessState = new int[15][15];
public static int flag = 1;
public boolean isBlack = true;
public void paint(Graphics g) {
super.paint(g);
//强制类型转换得到Graphics子类Graphics2D对象
Graphics2D g2 = (Graphics2D)g;//又得到一支笔
//先JPanel绘制背景图片
// g2.drawImage(image,0,0,1600,900,null);
//设置画笔颜色
g2.setColor(Color.CYAN);
//填充规定区域
g2.fill3DRect(50, 50, 700, 700, true);
//再设置画笔颜色,画直线
g2.setColor(Color.black);
//设置画出直线的宽度
g2.setStroke(new BasicStroke(3));
//绘制下棋区域
for(int i = 1;i < 16;i ++) {
g2.drawLine(50,50*i,750,50*i );
}
for(int i = 1;i < 16;i ++) {
g2.drawLine(50*i,50,50*i,750 );
}
//画外框
//设置画笔宽度
g2.setStroke(new BasicStroke(5));
g2.drawLine(25,25,775, 25);
g2.drawLine(25,775,775, 775);
g2.drawLine(25,25,25, 775);
g2.drawLine(775,25,775, 775);
//画四个黑色圆
g2.fillOval(240, 240, 20, 20);
g2.fillOval(540, 240, 20, 20);
g2.fillOval(240, 540, 20, 20);
g2.fillOval(540, 540, 20, 20);
//填充框框与下棋区域之间的区域
g2.setColor(new Color(176, 166, 100, 254));//设置画笔颜色
g2.fillRect(26, 26, 749, 23);
g2.fillRect(26, 49, 23, 725);
g2.fillRect(49, 752, 725, 23);
g2.fillRect(752, 49, 23, 703);
//检查chessState状态,如果棋盘位置游子则打印对应的棋子
for(int i = 0;i<15;i++){
for(int j=0;j<15;j++){
if(chessState[i][j]==1){
g2.setColor(Color.BLACK);
//计算落子位置
int pos_x = 50+i*50;
int pos_y = 50+j*50;
怎么再实现悔棋和五子棋输赢判断