一个简单GUI

来源:百度知道 编辑:UC知道 时间:2024/06/17 03:10:18
import java.awt.*;

public class CenterPanel {
public static void main(String args[]) {
new MyFrame3(300,300,400,300,Color.BLUE);
}
}

class MyFrame3 extends Frame{
private Panel p;
MyFrame3(int x,int y,int w,int h,Color c){
super("FrameWithPanel");
setLayout(null);
setBounds(x,y,w,h);
setBackground(c);
p = new Panel(null);
p.setBounds(w/4,h/4,w/2,h/2);
p.setBackground(Color.YELLOW);
add(p);
setVisible(true);
}
}

麻烦分析下这个程序中calss MyFrame3中的是怎样的思想,前面那点点不懂。
在设置标题那里用super()是什么意思啊?

class MyFrame3 extends Frame{
private Panel p; //定义私有布局块
MyFrame3(int x,int y,int w,int h,Color c){//构造方法
super("FrameWithPanel"); //设置标题
setLayout(null); //设置布局格式为null
setBounds(x,y,w,h); //(x,y)定义图在屏幕上的 w h 图的宽度和高度
setBackground(c); //背景色
p = new Panel(null); //子块
p.setBounds(w/4,h/4,w/2,h/2);//同上
p.setBackground(Color.YELLOW); //同上
add(p); //子块加入主块中
setVisible(true); //显示视图
}
}