java 简单的扫雷游戏
2020-11-23 08:57
标签:扫雷游戏 java java 简单的扫雷游戏 标签:扫雷游戏 java 原文地址:http://blog.csdn.net/huolei_blog/article/details/24599871//扫雷游戏
package Bible001;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class Mine extends MouseAdapter {
private JFrame mainFrame;
private int[][] data;
private JButton[][] buttons;
private JButton startJB;
private Label l;
private int row;
private int col;
private int mineNumber;
private int mineCount;
private boolean isOver;
public Mine(){
row=15;
col=15;
mainFrame=new JFrame("扫雷v1.0");
data=new int[row][col];
buttons=new JButton[row][col];
startJB=new JButton("Start");
l=new Label("welcome to mine!");
mineNumber=row*col/7;
}
public void init(){
JPanel north=new JPanel();
JPanel center=new JPanel();
JPanel south=new JPanel();
north.setLayout(new FlowLayout());
center.setLayout(new FlowLayout());
south.setLayout(new GridLayout(row,col,4,4));
mainFrame.setLayout(new BorderLayout());
mainFrame.add(north,BorderLayout.NORTH);
mainFrame.add(center,BorderLayout.CENTER);
mainFrame.add(south, BorderLayout.SOUTH);
north.add(l);
startJB.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
for(int i=0;i