?? gameframe2.java
字號(hào):
// 程序:AWT元件事件處理
// 范例文件:GameFrame2.java
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.util.*;
class GameFrame2 extends Frame
implements WindowListener,ActionListener
{
Panel main,top,center;
Menu MU;
MenuBar MB;
MenuItem MI1,MI2;
InfoDialog DW;
public GameFrame2(String Title,int AppletWidth,int AppletHeight,
Applet Game)
{
super(Title);
main = new Panel();
top = new Panel();
center = new Panel();
DW = new InfoDialog(this,"基本信息",true);
addWindowListener(this);
main.setLayout(new BorderLayout());
center.setLayout(new CardLayout());
main.add(top,BorderLayout.NORTH);
main.add(center,BorderLayout.CENTER);
top.add(new Button("按鈕1"));
top.add(new Button("按鈕2"));
center.add(Game,"main");
add(main);
MB = new MenuBar();
MU = new Menu("選項(xiàng)");
MU.add(MI1 = new MenuItem("基本信息"));
MU.add(MI2 = new MenuItem("離開(kāi)游戲"));
MB.add(MU);
setMenuBar(MB);
MI1.addActionListener(this);
MI2.addActionListener(this);
setResizable(false);
setSize(AppletWidth,AppletHeight + 100);
show();
}
public void windowClosing(WindowEvent e)
{
dispose();
}
public void windowOpened(WindowEvent e){}
public void windowClosed(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowActivated(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == MI1)
{
DW.show();
}
else if(e.getSource() == MI2)
dispose();
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -