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