📄 closedialog.java
字号:
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
class CloseDialog extends Dialog implements ActionListener
{
Panel P1,P2;
Button B1,B2;
fly Game;
public CloseDialog(fly Game,Frame owner)
{ //关闭游戏,父类为对话框
super(owner,"离开游戏...",true);
this.Game = Game; //this为类变量,Game为传入参数
this.setBounds(200,250,200,200);
setLayout(new GridLayout(2,1));
P1 = new Panel();
P2 = new Panel();
P1.add(new Label("真的要离开吗???"));
P2.add(B1 = new Button("确定"));
P2.add(B2 = new Button("取消"));
B1.addActionListener(this);
B2.addActionListener(this);
add(P1);
add(P2);
pack();
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == B1)
{
Game.StartGame=true;
}
else if(e.getSource() == B2)
{
Game.StartGame=false;
Game.newThread.resume();
}
hide();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -