报的错误
F:\javaWS\javaTXT>javac Example6_6.java
Example6_6.java:10: 错误: 对super的调用必须是构造器中的第一个语句
        super(s);
             ^
Example6_6.java:37: 错误: 无法将类 MyDialog中的构造器 MyDialog应用到给定类型;
            dialog = new MyDialog(this,"水果");
                     ^
  需要: 没有参数
  找到: MyWindow,String
  原因: 实际参数列表和形式参数列表长度不同
Example6_6.java:42: 错误: 无法将类 MyDialog中的构造器 MyDialog应用到给定类型;
            dialog =new MyDialog(this,"食品");
                    ^
  需要: 没有参数
  找到: MyWindow,String
  原因: 实际参数列表和形式参数列表长度不同
Example6_6.java:53: 错误: 对super的调用必须是构造器中的第一个语句
        super(F,s,true);//模态
             ^
Example6_6.java:77: 错误: 无法将类 MyWindow中的构造器 MyWindow应用到给定类型;
        window = new MyWindow("带对话框窗口");
                 ^
  需要: 没有参数
  找到: String
  原因: 实际参数列表和形式参数列表长度不同
5 个错误

解决方案 »

  1.   

    楼主构造函数和成员函数都分不清楚,你哪里有什么构造函数.构造函数是函数名与类名相同并且不带任何返回值类型的,你void MyWindow这样写不是构造函数而是成员函数。楼主好好补习下java的方法和构造函数的区别
      

  2.   

    void MyWindow(String s){
    去掉void 试试,构造函数不能有返回类型,连void也不能有。加上void就不认为是构造函数了。
      

  3.   


    import java.applet.*;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class MyWindow extends JFrame implements ActionListener{
        private JButton button1,button2;
        private static int flg=0;
        private static JTextField text1,text2;
        void MyWindow(String s){
            super(s);//这里
            Container con = this.getContentPane();
            con.setLayout(new GridLayout(2,2));
            this.setSize(200,100);
            this.setLocation(100,100);
            button1 = new JButton("选择水果");
            button2 = new JButton("选择食品");
            button1.addActionListener(this);
            button2.addActionListener(this);
            text1 = new JTextField(20);
            text2 = new JTextField(20);
            con.add(button1);
            con.add(button2);
            con.add(text1);
            con.add(text2);
            this.setVisible(true);
            this.pack();
        }
        public static void returnName(String s){
            if(flg ==1)
                text1.setText("选择的水果是:"+s);
            else if(flg == 2)
                text2.setText("选择的食品是:"+s);
        }
        public void actionPerformed(ActionEvent e){
            MyDialog dialog;
            if(e.getSource()==button1){
                dialog = new MyDialog(this,"水果");
                dialog.setVisible(true);
                flg =1;
            }
            else if(e.getSource()==button2){
                dialog =new MyDialog(this,"食品");
                dialog.setVisible(true);
                flg=2;
            }
        }
    }
    class MyDialog extends JDialog implements ActionListener{
        JLabel title;
        JTextField text;
        JButton done;
        void MyDialog(JFrame F,String s){
            super(F,s,true);//模态 ////和这里
            Container con = this.getContentPane();
            title = new JLabel("输入"+s+"名称");
            text = new JTextField(10);
            text.setEditable(true);
            con.setLayout(new FlowLayout());
            con.setSize(200,100);
            setModal(false);
            done = new JButton("确定");
            done.addActionListener(this);
            con.setVisible(true);
            this.pack();
        }
        public void actionPerformed(ActionEvent e){
            MyWindow.returnName(text.getText());
            setVisible(false);
            dispose();
        }
    }
    public class Example6_6 extends Applet{
        public static void main(String[] args){
        MyWindow window;
        MyDialog dialog;
         
            window = new MyWindow("带对话框窗口");
        }
    }
      

  4.   

    该是这个package bl.se;import java.applet.*;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class MyWindow extends JFrame implements ActionListener{
        private JButton button1,button2;
        private static int flg=0;
        private static JTextField text1,text2;
       MyWindow(String s){//注意构造函数的写法
            //super();//这里
            Container con = this.getContentPane();
            con.setLayout(new GridLayout(2,2));
            this.setSize(200,100);
            this.setLocation(100,100);
            button1 = new JButton("选择水果");
            button2 = new JButton("选择食品");
            button1.addActionListener(this);
            button2.addActionListener(this);
            text1 = new JTextField(20);
            text2 = new JTextField(20);
            con.add(button1);
            con.add(button2);
            con.add(text1);
            con.add(text2);
            this.setVisible(true);
            this.pack();
        }
        public static void returnName(String s){
            if(flg ==1)
                text1.setText("选择的水果是:"+s);
            else if(flg == 2)
                text2.setText("选择的食品是:"+s);
        }
        public void actionPerformed(ActionEvent e){
            MyDialog dialog;
            if(e.getSource()==button1){
                dialog = new MyDialog("水果");
                dialog.setVisible(true);
                flg =1;
            }
            else if(e.getSource()==button2){
                dialog =new MyDialog("食品");
                dialog.setVisible(true);
                flg=2;
            }
        }
    }
    class MyDialog extends JDialog implements ActionListener{
        JLabel title;
        JTextField text;
        JButton done;
        MyDialog(String s){//没用的参数不要传进去
           // super(F,s,true);//模态 ////和这里
            Container con = this.getContentPane();
            title = new JLabel("输入"+s+"名称");
            text = new JTextField(10);
            text.setEditable(true);
            con.setLayout(new FlowLayout());
            con.setSize(200,100);
            setModal(false);
            done = new JButton("确定");
            done.addActionListener(this);
            con.setVisible(true);
            this.pack();
        }
        public void actionPerformed(ActionEvent e){
            MyWindow.returnName(text.getText());
            setVisible(false);
            dispose();
        }
    }
    public class Example6_6 extends Applet{
        public static void main(String[] args){
        MyWindow window;
        MyDialog dialog;
         
            window = new MyWindow("带对话框窗口");
        }
    }
      

  5.   

    你那个是什么构造函数啊!乱搞,将void去掉
      

  6.   

    void MyWindow(String s){ 这是普通方法