我嘗試運行下面的源代碼,但得到設置配置,同時保持的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