新手 谁帮忙看下哪出问题了
import java.awt.*;
public class asdf extends Frame{
public static void main(String[] args)
{
Frame f = new Frame("zyp");
Panel p = new Panel(null);
f.setLayout(null);
f.setLocation(200,200);
f.setBackground(Color.black);
p.setBackground(Color.green);
p.setSize(500,500);
f.add(p);
f.setVisible(true);
f.pack();
}
}
运行后为什么是这样呢,是不是必须初始化Frame的大小,能不能根据Panel的大小自动调整Frame的大小呢?