ActionListener等不识别,说明引入的package不够

解决方案 »

  1.   

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    /**
     * <p>Title: </p>
     * <p>Description: </p>
     * <p>Copyright: Copyright (c) 2004</p>
     * <p>Company: </p>
     * @author not attributable
     * @version 1.0
     */public class demo extends JPanel{
      JButton jButton1 = new JButton();
      
      public demo(){
        JButton A=new JButton("A");
        try {
          jbInit();
        }
        catch(Exception e) {
          e.printStackTrace();
        }
      }  public static void main(String[] args) {
        ok A = new ok();
        A.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        A.show();
      }
      private void jbInit() throws Exception {
        jButton1.setText("jButton1");
        jButton1.addActionListener(new demo_jButton1_actionAdapter(this));
        this.add(jButton1, null);
      }  void jButton1_actionPerformed(ActionEvent e) {
        //add your action
      }
    }
      

  2.   

    把private修饰符去掉应该就可以了!
      

  3.   

    import java.awt.event.*;
    event要小写吧?