//下面的代码用了匿名内部类。
    jButton1.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {
        jButton1_actionPerformed(e);
      }
    });

解决方案 »

  1.   

    以为这个类只用一次,所以把它写成内部类。所以你可以连名字都不用给他启。例如:
    public class extends JApplet
    {
      JButton bu = new JButton("click");
      pubic void init()
     {
      bu.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent e)
      { System.out.prinltn("");}
    });
     }
    }
      

  2.   

    匿名内部类和一般的内部类差不多,只是用一次罢了。
    但是不能有任何 修饰词,和 普通的 inner class一样用
    e.g:
    this.addWindowListener(new WindowAdapter (){
    public void windowClosing(WindowEvent e){
    System.exit(0); }});
      

  3.   

    同意:
     qxjavajava(射手座 =--->听歌看海
    Anubis12345(东大d徒然草) 
      

  4.   

    Inner classes can be created within methods. This is something that GUI builders like Borland JBuilder do a great deal of when creating Event handlers.Here is an example of such automatically generated code
    buttonControl1.addMouseListener(new java.awt.event.MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            buttonControl1_mouseClicked(e);
          }
        });
    Note the keyword new just after the first parenthesis. This indicates that an anonymous inner class is being defined within the method addMouseListener. This class could have been defined normally with a name which might make it easier for a human to read, but as no processing is done with it anywhere else, having a name does not help much.If you create such code by hand, it is easy to get confused over the number and level of brackets and parentheses. Note how the whole structure ends with a semi colon, as this is actually the end of a method call.As you might guess an anonymous class cannot have a constructor. Think about it, a constructor is a method with no return value and the same name as the class. Duh! we are talking about classes without names. An anonymous class may extend another class or implement a single interface. This peculiar limit does not seem to be tested in the exam. 
      

  5.   

    snowrain(雪雨)  我建议你看effective Java programming Language guide
    我也帮你顶! 我明天再看看,然后跟你聊聊,今天先走一步~~
      

  6.   

    建议看一下java核心技术1,里面写得比较明白:)
      

  7.   

    强烈建议你看看thingking in java 2的匿名类部分,在263到268页之间,
    我看这本书的时候在这里就很困难,现在有些东西还不是很清楚