TestTextField.java的错误究竟在哪了? 
import java.awt.*;
 import java.awt.event.*;
 
public class TestTextField implements ActionListener{
     TextField name;
     TextField password;
     public static void main(String[] args)  {
        TestTextField ttf = new TestTextField();
        ttf.createUI();
      }
        
     public void createUI(){   
         Frame f = new Frame("登录界面");
         f.add(new Label("please input in your users'information:"),"North");
         
         Panel p1 = new Panel();
         p1.setLayout(new BorderLayout());
         Panel p11 = new Panel();
         p11.setLayout(new GridLayout(2,1));
         p11.add(new Label("用户名:"));
         p11.add(new Label("密码:"));
         
         Panel p12 = new Panel();
         p12.setLayout(new GridLayout(2,1));
          name = new TextField(10);
          name.addActionListener(this);
          password = new TextField(10);
          password.addActionListener(this);
         p12.add(name);
         p12.add(password);
         p1.add(p11,"West");
         p1.add(p12,"Center");
         f.add(p1,"Center");
         
        Panel p2 = new Panel();
        Button submit = new Button("提交");
        submit.addActionListener(this);
        reset.addActionListener(this); 
        Button reset = new Button("重置");
        p2.add(submit);
        p2.add(reset);
        f.add(p2,"South");
         f.setSize(200,160);
         f.setLocation(300,200);
         f.setVisible(true);
         f.addWindowListener(new WindowAdapter(){
             public void windowClosing(WindowEvent e){
                 System.exit(0);
              }
          }); 
    }
       public void clear(){
         name.setText("");
         password.setText("");
      }       public void actionPerformed(ActionEvent e){
          String s =e.getActionCommand();
          if(s.equals("重置")){
              this.clear();
           }
          else if(s.equals("提交")||(e.getSource()==name)||
          (e.getSource()==password)){
               this.submit();
           }
        }       public void submit(){
            String n = name.getText();
            String psw = password.getText();
            System.out.println("用户名:"+n+"\t密码:"+psw);
        }
}

解决方案 »

  1.   

    帮你看了下, 发现一处 ,reset还未定义就先使用了 修改下吧 
    原:  Button submit = new Button("提交");
      submit.addActionListener(this);
      reset.addActionListener(this);  
      Button reset = new Button("重置");改后  Button submit = new Button("提交");
      submit.addActionListener(this);
      Button reset = new Button("重置");
      reset.addActionListener(this);  
      

  2.   

    在命令提示符窗口中编译时,为什么会出现提示:文件不包含类Frame,请问AWT包含了类Frame吗?