【发布时间】:2016-01-20 20:47:05
【问题描述】:
我创建了一个闹钟类,部分代码是挑选播放的音乐。我创建了一个按钮,单击该按钮会打开一个对话框来选择音乐按钮。但是,我在这门课上遇到了超级问题,这是我的其他窗口没有给我的问题。忍受我,我在这一切都很糟糕。 这是音乐对话课(如果需要我的其他课来回答,请告诉我)
import java.awt.*;
import java.io.*;
public class SetMusicDialog extends Dialog
{
public static String sng;
public SetMusicDialog()
{
super ( "Set Music");
Panel mpanel;
Font l = new Font("Helvetica", Font.ITALIC, 12);
setFont(l);//sets font
setBackground(Color.cyan);
Panel f = new Panel();
f.add("West", new Button("Death Grips"));
f.add("East", new Button("Siren"));
add("South",f);
pack(); // make it just fit
resize(preferredSize());
move(200,200);
}
public boolean handleEvent1 (Event evt)
{
switch (evt.id)
{
case Event.ACTION_EVENT:
if("Death Grips".equals(evt.arg))
{
sng= "breakmirrors.wav";
}
else if("Siren".equals(evt.arg))
{
sng= "bip.wav";
}
}
}
}
这是我不断收到的错误:
Error: no suitable constructor found for Dialog(java.lang.String)
constructor java.awt.Dialog.Dialog(java.awt.Frame) is not applicable
(argument mismatch; java.lang.String cannot be converted to java.awt.Frame)
constructor java.awt.Dialog.Dialog(java.awt.Dialog) is not applicable
(argument mismatch; java.lang.String cannot be converted to java.awt.Dialog)
constructor java.awt.Dialog.Dialog(java.awt.Window) is not applicable
(argument mismatch; java.lang.String cannot be converted to java.awt.Window)
【问题讨论】:
-
一开始你写了 super("Set Music" ) 但是你的父类没有这样的构造函数......我建议你检查这个 [link] (stackoverflow.com/questions/508723/…)跨度>
-
嗨,对不起。把标题搞砸了现在已编辑。