📄 mainframe.java
字号:
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;
/**
* 程序的开始位置,由它来调用其他一些东西.
* @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());//程序的关闭按钮.
this.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
Constant cons = new Constant();//用于得到雷数count,方块的横长个数lengthx,纵长个数lengthy.
GameMain gameMain = new GameMain(cons.getCount(), cons.getLengthx(), cons.getLengthy());
//调用Constant类在的数据来实现实例化GameMain
gameMain.start();
}
}
class MyWindowEvent extends WindowAdapter {//关闭按钮的实现
public void windowClosing(WindowEvent e){
System.exit(0);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -