日期:2014-05-20  浏览次数:20621 次

求救,我不知道怎么错了
import   java.awt.*;
import   java.awt.event.*;
public   class   MyFrame2   extends   Frame{
private   int   x=200,y=200;
private   int   w=200,h=200;
Panel   p1=new   Panel();
public   MyFrame2(String   n){
this(n,x,y,w,h);     //看这里,怎么错了啊,错在哪里,谢谢指教
}
public   MyFrame2(String   s,int   x,int   y,int   w,int   h){
super(s);
this.x=x;
this.y=y;
this.w=w;
this.h=h;
this.setLayout(null);
p1.setBackground(Color.yellow);
p1.setBounds(w/4,h/4,w/2,h/2);
                  }
}

------解决方案--------------------
不能在调用父类型构造函数之前引用 x,y,等变量
public MyFrame2(String n){
this(n,x,y,w,h); //看这里,怎么错了啊,错在哪里,谢谢指教
}
这段你该成如下
public MyFrame2(String n){
super(n); //
}

------解决方案--------------------
关注~~如果楼主 想到 怎么半了 请贴 一下 谢谢