package com.xinxi.mine;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
/**
* 程序的開始位置,由它來調(diào)用其他一些東西.
* @author Administrator
*
*/
public class MainFrame extends JFrame implements ActionListener{
private JButton button;
public static void main(String[] args) {//程序起始位置
MainFrame mainWin = new MainFrame();
mainWin.start();
}
public void start(){
button = new JButton("Button");
this.getContentPane().add(button);
button.addActionListener(this);
this.setLocation(300, 300);
this.setSize(300, 200);
this.addWindowListener(new MyWindowEvent());//程序的關(guān)閉按鈕.
this.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
Constant cons = new Constant();//用于得到雷數(shù)count,方塊的橫長個(gè)數(shù)lengthx,縱長個(gè)數(shù)lengthy.
GameMain gameMain = new GameMain(cons.getCount(), cons.getLengthx(), cons.getLengthy());
//調(diào)用Constant類在的數(shù)據(jù)來實(shí)現(xiàn)實(shí)例化GameMain
gameMain.start();
}
}
class MyWindowEvent extends WindowAdapter {//關(guān)閉按鈕的實(shí)現(xiàn)
public void windowClosing(WindowEvent e){
System.exit(0);
}
}