/**
*Title:TestPanel_13.java
*Description:1.在frame中添加panel 2.区分Frame中setBounds和Panel中setBounds的区别 3.setBounds会用new Color()来改变颜色.
*@Copyright:
*@Company:
*@autor:firefly
*@version:1.0
*@time:2012.10.2
*/
import java.awt.*;
public class TestPanel_13 {
public static void main(String[] args) {
Frame f = new Frame("Java Frame With Panel!");
Panel p = new Panel(null);
f.setLayout(null);
f.setBounds(300, 300, 500, 500); //frame的setBounds是针对屏幕左上角的像素数。
f.setBackground(new Color(0, 0, 102));//这里new一个color,里面的参数是代表红、黄、蓝三元色。
p.setBounds(50, 50, 400, 400); //panel的setBouds是针对Frame的左上角的像素.
p.setBackground(new Color(204, 204, 255));
f.add(p);
f.setVisible(true);
}
}