求五子棋代码(要java写的),有界面

来源:百度知道 编辑:UC知道 时间:2024/05/28 16:06:58
谁能给我个java写的五子棋代码,要有注释的,谢谢了,可以运行的话,30分就是你的了

import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
import java.awt.Color;

public class WuZhiqi extends Applet implements ActionListener, MouseListener,
MouseMotionListener, ItemListener {
int color = 0;// 旗子的颜色标识 0:白子 1:黑子

boolean isStart = false;// 游戏开始标志

int bodyArray[][] = new int[16][16]; // 设置棋盘棋子状态 0 无子 1 白子 2 黑子

Button b1 = new Button("游戏开始");

Button b2 = new Button("重置游戏");

Label lblWin = new Label(" ");

Checkbox ckbHB[] = new Checkbox[2];

CheckboxGroup ckgHB = new CheckboxGroup();

public void init() {
setLayout(null);

addMouseListener(this);
add(b1);
b1.setBounds(330, 50, 80, 30);
b1.addActionListener(this);
add(b2);
b2.setBounds(330, 90, 80, 30);
b2.addActionListener(this);
ckbHB[0] = new Checkbox("白子先", ckgHB, false);