/*
时间:2015年3月15日20:24:20
测试Gui中的Frame和Panel
Frame是指带有标题和边框的顶层窗口。窗体的大小包括为边框指定的所有区域。
Component是一个具有图形表示能力的对象,可在屏幕上显示,并可与用户进行交互。典型图形用户交互的按钮,复选框,和滚动条都是组件。
public component add(Component comp);将指定组件添加到此容器的尾部。
*/
import java.awt.*;
public class TestFrameWithPanel {
public static void main(String[] args) {
Frame f = new Frame("My TestFrame");
Panel p = new Panel();
f.setSize(300, 300);
f.setBackground(Color.blue);
p.setSize(200, 200);
p.setBackground(Color.red);
f.setLayout(null);
f.add(p);
f.setVisible(true);
}
}
public static void main(String[] args) {
Frame f = new Frame("My TestFrame");
Panel p = new Panel();
f.setSize(300, 300);
f.setBackground(Color.blue);
p.setSize(200, 200);
p.setBackground(Color.red);
f.setLayout(null);
f.add(p);
f.setVisible(true);
}
}