MyJFrame.java
package chi1.JFrame;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class MyJFrame extends JFrame implements MouseListener {
private static final long serialVersionUID = -46847020668994298L;
BufferedImage buff = null; // 声明对象,为获取图片
int x , y ;
// 保存所有的点多的坐标
int[][] allChess = new int[15][15] ; // 用一个二维数组保存黑白子信息。
String show1 = "" ; // 默认黑方下棋
//默认下黑子 , 判断下什么棋子。bool=true 下黑子 ; bool=false 下白子
// boolean bool = true ;
// 判断是否赢了比赛, 如果赢了比赛, 就不能再继续下棋了,
boolean win =true ;
public MyJFrame(){
int width = Toolkit.getDefaultToolkit().getScreenSize().width ;
int height = Toolkit.getDefaultToolkit().getScreenSize().height ;
this.setTitle("五子棋");
this.setResizable(false);
this.setSize(500,550 );
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLocation((width-500)/2 , (height-550)/2);
this.repaint();
this.addMouseListener(this);
try {
buff = ImageIO.read(new File("e:/wzq.jpg" ));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
this.setVisible(true);
};
// boolean rekai = true ;
int select = 0 ;
boolean bool2=true ;
@Override
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
// System.out.println(e.getX());
// System.out.println(e.getY());
}
@Override
public void mousePressed(MouseEvent e) {
boolean bool = true ;
for(int x = 0 ; x<15 ; x++){
for(int y = 0 ; y < 15 ; y++){
if(allChess[x][y]==0){