你可以不写,但它也得自动调用父类的无参构造函数的,
public Frame(String title):
      
Constructs a new, initially invisible Frame object with the specified title

解决方案 »

  1.   

    Frame(String str) 表示建立一个名字为str 的Frame实例;如果不调用,当然也可以通过编译
    但是这样就会调用没有参数的 Frame(), 那 MYframe(String str)里的str就没有作用了。即  MYframe fr=new MYframe("Hello OUt There!");
                              ---------------------  这里无论输入什么,结果都一样。
      

  2.   

    你需要在子类中也同样定义一个无参构造函数,如果你没定义,并且已经定义了另外的构造函数,系统是不会为你提供默认的
    import java.awt.*;
    public class MYframe extends Frame{
       public static void main(String arg[]){
           MYframe fr=new MYframe("Hello OUt There!");
           Panel pan=new Panel();
           fr.setSize(200,200);
           fr.setBackground(Color.blue);
           fr.setVisible(true);
           pan.setSize(100,100);
           pan.setBackground(Color.green);
           fr.add(pan);
           }
            public MYframe(String str){
          super(str);}       public MYfrmae(){   //提供无参构造函数
          super();}
                  }