📄 play.java
字号:
package com.zhoutenghn;
import java.awt.*;
import java.awt.event.*;
public class Play extends Frame{
public static final int locationx = 500 ;
public static final int locationy = 300 ;
private String str1 = "请注意健康游戏时间!\n 开始玩游戏,单击确定!";
private String str2 = "游戏说明:黄色坦克为我方!“1”复活!空格可发导弹";
public static void main (String args[]){
new Play().launch();
}
public void launch(){
this.setTitle("坦克大战");
this.setLocation(locationx, locationy);
this.setResizable(false);
this.setSize(100,200);
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
Panel panel1 = new Panel();
Panel panel2 = new Panel();
panel2.setLayout(new BorderLayout());
Button button1 = new Button("确认");
Button button2 = new Button("取消");
button1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
new BeginPlay().launch();
}
});
button2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
System.exit(0);
}
});
Label label1 = new Label(str1);
Label label2 = new Label(str2);
panel2.add(label1,BorderLayout.NORTH);
panel2.add(label2,BorderLayout.SOUTH);
this.setLayout(new BorderLayout());
//this.add(label1,BorderLayout.NORTH);
panel1.add(button1);
panel1.add(button2);
this.add(panel2,BorderLayout.NORTH);
this.add(panel1,BorderLayout.SOUTH);
pack();
this.setVisible(true);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -