我尝试运行下面的源代码,但得到设置配置,同时保持的JPanel型
类型不匹配:不能从CustomJPan转换的JPanel
错误。有人可以帮忙吗?请原谅,我从头顶开始。
public class rebuiltgui extends JApplet {
public void init() {
JPanel jpan = new CustomJPan();
}
}
class CustomJPan {
public JPanel CustomJPan() {
thispan = new JPanel();
thispan.setBackground(Color.red);
return thispan;
}
public changeColour() {
// Change colour to blue here
}
}
http://docs.oracle.com/javase/tutorial/java/javaOO/classes.html – 2013-02-23 04:30:51
对不起,我以为我是子类(facepalm) – 2013-02-23 04:33:22