在addActionListener()里面的是一个匿名类,这是Java比较特殊的语法(相对与C++)。
这样做可以使代码比较简洁紧凑,不过你也可以这样写啊:/*完整的实现一个类*/
class MyLisenter implements ActionLisnter {
  public void actionPerformed(ActionEvent e) {
    /......
  }
}/*然后调用*/
...............
...............
jButton  jButton1=new jButton();
MyListener jellen = new MyListener();  //显式声明
...............
jButton1.addActionListener(jellen);

解决方案 »

  1.   

    这个是直接引用java.awt.event包里面的方法,可以在程序的开始定义,也可以直接写在这个里面的
      

  2.   

    匿名类
    new了的东西叫对象,他不是方法、函数
    在里面写方法是因为接口不能实例化
    jButton1.addActionListener(new  java.awt.event.ActionListener(){
       public void actionPerformed(ActionEvent e){
    }
    });
      

  3.   

    new  java.awt.event.ActionListener()
    {
       public void actionPerformed(ActionEvent e);
    }
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    上面就是你的jButton1.addActionListener()方法(或函数)的参数查jdk帮助可知:
    addActionListener
    public void addActionListener(ActionListener l)
    Adds the specified action listener to receive action events from this button. Action events occur when a user presses or releases the mouse over this button. If l is null, no exception is thrown and no action is performed. Parameters:
    l - the action listenernew出来的东西就是一个对象的引用
      

  4.   

    to huaf
            "女孩子学什么编程。^_^"
    --------------------------------
    怪事,女孩子学编程有什么问题,虽然我是男的,不平ing
      

  5.   

    很简单啊,就是实现JButton的监听。
    class Test extend JPanel impelements ActionListener
    Test(){
    JButton button=new JButton("click")
    button.addActionListener(this)
    }
    public void actionPerformed(ActionEvent e){
    ………………………………
    }
    这样应该看得懂了吧。
      

  6.   

    这是JAVA的一种写法,传递的参数可以是一个新的对象
      

  7.   

    在addActionListener()里面的是一个匿名类,这是Java比较特殊的语法
      

  8.   

    在addActionListener()里面的是一个匿名类 对象
      

  9.   

    jdk帮助都是英文的,我看不懂呀
    哪里有什么中文的jdk帮助看呀??????小女子谢了!