?? 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 + -