Button 没有加事件侦听器
bt.addActionListener(this);

解决方案 »

  1.   

    以下代码测试通过:import java.awt.event.*;
    import java.applet.*;
    import java.awt.*;
    import java.util.EventObject;public class TestApplet extends Applet implements ActionListener{
        private String s=null;
        private TextField tf;
        private Button bt;
        private Label lb;    public void init(){
           s="This is a test";
           tf=new TextField("one");
           this.add(tf);
           bt=new Button("button");
           bt.addActionListener(this);
           this.add(bt);
           lb=new Label("this is a label");
           this.add(lb);
        }    public void actionPerformed(ActionEvent ae) {
          System.out.println(ae.getSource().toString());
             if (ae.getSource() == bt) {
                     //tfAnswer.setText("You clicked the JButton");
                     //bt.setLabel("this is a test");
                     tf.setText("DDDDDDDDDDDDDDD");
                }
       }}
      

  2.   

    没有给按钮对象注册事件,怎么会有反应呢?
    楼上给你补上了: bt.addActionListener(this);