问题描述
public class xxx extends GroupLayout {
public xxx(Container host,String...arg) {
//code
}
}
解决方法
GroupLayout
没有无参数的构造函数,这意味着Java不能对其构造函数进行隐式调用,因此您将得到一个编译时错误。您只需要调用super(host)
作为方法的第一行,即可调用GroupLayout
确实具有的构造函数。试试:
public class SubGroupLayout extends GroupLayout {
public SubGroupLayout(Container host,String ...arg) {
super(host);
// then,do your own code here
}
}
有关更多详细信息,请参见Using the Keyword super和super() in constructor。