首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

求救,小弟我不知道如何错了

2012-03-07 
求救,我不知道怎么错了importjava.awt.*importjava.awt.event.*publicclassMyFrame2extendsFrame{privat

求救,我不知道怎么错了
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); //
}

[解决办法]
关注~~如果楼主 想到 怎么半了 请贴 一下 谢谢

热点排行