java扫雷带注释源代码 java实现扫雷游戏

求助Java扫雷源码注释import java.awt.*;
import java.util.*;
import java.io.*;
import javax.swing.*;
import javax.swing.Timer;
import java.awt.event.*;
import javax.swing.border.*;
/**
* pTitle:扫雷/p
*
* pDescription:学JAVA以来做的第一个游戏,程序中可能还有些BUG,希望大家提出来供一起探讨,
*如果要测试记录文件,可以把雷的数量改的少一点,
*arithmetic中的while(landmintTally99), button_mouseClicked中的
*if((landmineNum-1)==0),有3处,表示还剩的雷数.completeGame中的
*for (int i=0; i99; i++)/p
* pCopyright: Copyright (c) 2006/p
*
* pCompany: private /p
*
* @author cqp
* @version demo
*/
public class shaolei extends JFrame {
/**类的属性和控件实例化*/
ImageIcon ButtonIcon;//按钮的图片;
HashMap map = new HashMap();//雷和数字的状态,键为位置(0-479),值为状态,0-6为数字,7为雷;
HashMap flag_landmine = new HashMap();//按钮上打的标记,如问号,对勾和取消,8为标记雷,9为问号,10为默认值空;
JMenuBar file = new JMenuBar();//菜单栏;
JMenu game = new JMenu();//菜单按钮;
JMenuItem start = new JMenuItem();//菜单项;
JMenuItem record = new JMenuItem();//菜单项;
JMenuItem quit = new JMenuItem();//菜单项;
JMenuItem clearReocrd = new JMenuItem();//菜单项;
JMenu help = new JMenu();//菜单按钮;
JButton[] cardsBtn = new JButton[480]; //480个按钮;
JButton beginBtn = new JButton();//开始按钮;
JPanel pane = new JPanel();//雷区面板;
JPanel paneTime = new JPanel();//记数器所在的面板;
JOptionPane saveRecord = new JOptionPane();//保存记录对话框java扫雷带注释源代码;
JTextField landmineTally = new JTextField("99");//所剩雷的计数器;
JTextField timeTally = new JTextField("0");//时间计数器;
GridLayout gridLayout1 = new GridLayout();//网格布局;
Timer timer;//线程设施;
String[] landmine = new String[99];//存放雷的位置java扫雷带注释源代码,用来判断雷的位置是否重复;
slFrame_button_actionAdatper[] buttonClick =new slFrame_button_actionAdatper[480];//雷区按钮的事件类;
int mouseKey=0;//得到鼠标先按下的哪个键,用来判断鼠标是否同时按下了左右键;
int timeCount = 0;//时间计数器;
/**构造方法*/
public shaolei() {
try {
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
/**界面设置*/
private void jbInit() throws Exception {
getContentPane().setLayout(null);
this.setJMenuBar(file);
game.setText("游戏");
start.setText("开局");
start.addActionListener(new slFrame_start_actionAdapter(this));
record.setText("排行榜");
record.addActionListener(new slFrame_record_actionAdapter(this));
quit.setText("退出");
quit.addActionListener(new slFrame_quit_actionAdapter(this));
help.setText("帮助");
clearReocrd.setText("清除记录");
clearReocrd.addActionListener(new slFrame_clearReocrd_actionAdapter(this));
landmineTally.setBounds(new Rectangle(5, 5, 40, 25));
landmineTally.setBackground(new Color(0,0,0));
landmineTally.setForeground(new Color(255,0,0));
landmineTally.setFont(new java.awt.Font("Times New Roman", Font.BOLD, 20));
landmineTally.setBorder(BorderFactory.createBevelBorder(1));
landmineTally.setEditable(false);
timeTally.setBounds(new Rectangle(520, 5, 50, 25));
timeTally.setBackground(new Color(0,0,0));
timeTally.setForeground(new Color(255,0,0));
timeTally.setHorizontalAlignment(4);
timeTally.setFont(new java.awt.Font("Times New Roman", Font.BOLD, 20));
timeTally.setBorder(BorderFactory.createBevelBorder(0));
timeTally.setEditable(false);

推荐阅读