class LoginDialog does not have a constructor which takes no parameters, since there is a LoginDialog(JFrame parent)

解决方案 »

  1.   

    如果要写一个LoginDialog class的测试程序,应该怎么写?我还需要加什么method在test里面吗??
      

  2.   

    try
    class test 
    {
     static JFrame f;
     public static void main(String[] args) 
     {    f = new JFrame("This is a test");
        f.setSize(400, 150);
        Container content = f.getContentPane();
        content.setBackground(Color.white);
        content.setLayout(new FlowLayout()); 
        JButton jb = new JButton("Click Me");
        jb.addActionListener(new ActionListener() {
         public void actionPerformed ( ActionEvent ae ) 
    {
    LoginDialog ld = new LoginDialog(f);
         ld.userText = new JTextField("zongyi");
         ld.pwText = new JPasswordField("zongyi");    
    ld.show();
         }  });    content.add(jb);
        
        f.addWindowListener(new WindowAdapter()
        {
       public void windowClosing(WindowEvent event) 
    {
         System.exit(0);
       }
         });    f.setVisible(true);  
      }  
    }
      

  3.   

    LOGINDIALOG里面没有无参数的构造函数,
    你改一下好了,或者在调用上改,或者在类里改,都可以