import java.awt.*;
import java.awt.event.*;
import javax.swing.*;public class Test
{
public static void main(String[] args){
DFrame f=new DFrame();
f.setVisible(true);
}

}
class DFrame extends JFrame{
private aboutDialog adl;
public void DFrame()
{
setTitle("dasdas");
setSize(300,200);

JMenuBar bar=new JMenuBar();
setJMenuBar(bar);
JMenu file=new JMenu("file");
JMenuItem dl=new JMenuItem("");
bar.add(file);
file.add(dl);
dl.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event){
if(adl==null)
{
 adl=new aboutDialog(DFrame.this);
}

adl.setVisible(true);
}
});
}
class aboutDialog extends JDialog{
public void aboutDialog(JFrame frame){
super(frame,"aboutDialog",true);
}
}
}编译就同不过,我怎么想也不知道哪错了?
大家来帮帮忙!
错误提示如下:
--------------------Configuration: <Default>--------------------
C:\Documents and Settings\Administrator\桌面\Test.java:32: 找不到符号
符号: 构造函数 aboutDialog(DFrame)
位置: 类 DFrame.aboutDialog
                                         adl=new aboutDialog(DFrame.this);
                                             ^
C:\Documents and Settings\Administrator\桌面\Test.java:41: 对 super 的调用必须是构造函数中的第一个语句
                        super(frame,"aboutDialog",true);
                             ^
2 错误Process completed.

解决方案 »

  1.   

    class aboutDialog extends JDialog{ 
    public void aboutDialog(JFrame frame){ 
    super(frame,"aboutDialog",true); 

    这个是构造函数吗?
    构造函数是不带返回值的。你把这个void去掉,编译可通过。但是,实际上还是不对。public void DFrame() {
    ……
    }
    这个同样道理。不过你没有调用super,编译器把它当作一个普通函数处理了。
    super(frame, "aboutDialog", true);这样的方式只能在构造函书中出现。其余的应当是super.XXX呵呵……很像当年的我……
      

  2.   

    public void DFrame() 
    public void aboutDialog(JFrame frame)
    构造方法不带返回值。把这两个void 去掉。