我将让代码和错误进行讨论,因为我真的认为他们会说以外的所有内容,这应该不会发生! 有人知道如何进行编译吗?
码
class CountDownTimerGUI extends BHTimerGUI
{
private TimerJPanel control;
private TimerDisplayJPanel disp;
public CountDownTimerGUI(TimerJPanel control, TimerDisplayJPanel disp)
>> {
this.control = control;
this.disp = disp;
}
}
(
>>
表示错误所在的行)这将覆盖
BHTimerGUI
的构造函数,该构造函数如下: public BHTimerGUI(TimerJPanel control, TimerDisplayJPanel disp)
{
this.control = control;
this.disp = disp;
}
编译器错误
I:\Java\NetBeansProjects\Blue Husky's Timer 2.0.0\src\bhtimer\GUI.java:145: cannot find symbol
symbol : constructor BHTimerGUI()
location: class bhtimer.BHTimerGUI
{
NetBeans显示带有以下文本的 pop 窗口:
constructor BHTimerGUI in class bhtimer.BHTimerGUI cannot be applied to given types;
required: bhtimer.TimerJPanel,bhtimer.TimerDisplayJPanel
found: no arguments
reason: actual and formal argument lists differ in length
最佳答案
是的,这应该正在发生!您没有初始化父类(super class)构造函数。
尝试使用此构造函数:
public CountDownTimerGUI(TimerJPanel control, TimerDisplayJPanel disp){
super(control, disp);
this.control = control;
this.disp = disp;
}