?? gameframe.java
字號:
// 程序:跳脫瀏覽器的Applet
// 范例文件:GameFrame.java
import java.awt.*;
import java.applet.*;
class GameFrame
{
Frame gameFrame; //裝載Applet的窗口
Panel main,top,center; //main將包含top與center
public GameFrame(String Title,int AppletWidth,int AppletHeight,
Applet Game)
{
gameFrame = new Frame(Title); //建立窗口
main = new Panel(); //建立Panel
top = new Panel();
center = new Panel();
main.setLayout(new BorderLayout()); //main使用BorderLayout
center.setLayout(new CardLayout()); //center使用CardLayout
//top使用預設的FlowLayout
main.add(top,BorderLayout.NORTH); //將top置入main上方
main.add(center,BorderLayout.CENTER); //將center置入main中央
top.add(new Button("按鈕1")); //在top中置入兩個按鈕
top.add(new Button("按鈕2"));
center.add(Game,"main"); //在center中置入Applet
gameFrame.add(main,BorderLayout.CENTER); //在窗口中置入main
gameFrame.setResizable(false); //不可改變窗口大小
gameFrame.setSize(AppletWidth,AppletHeight + 100); //為何高度要加100
gameFrame.show(); //顯示窗口
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -