📄 mulpaneldemo.java
字号:
import java.awt.*;
public class MulPanelDemo
{
public static void main(String arg[])
{
Frame win = new Frame("my first GUI application");
win.setBackground(Color.red);
//创建Panel,把其布局管理改为BorderLayout
Panel p1 = new Panel();
p1.setLayout(new BorderLayout());
p1.add("North", new Button("ok"));
p1.add("South", new Checkbox("one", null, true));
p1.add("Center", new Checkbox("two"));
//创建Panel,使用其省却的FlowLayout布局管理
Panel p2 = new Panel();
p2.add(new Checkbox("three"));
Choice ColorChooser = new Choice();
ColorChooser.add("Green");
ColorChooser.add("Red");
ColorChooser.add("Blue");
p2.add(ColorChooser);
p2.add(new Label("label"));
win.add("East",new TextField("textfield"));
win.add("Center",p1);
//将Panel p1作为一个组件加到Frame中
win.add("West",p2);
//将Panel p2作为一个组件加到Frame中
win.pack();
win.show();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -