为JBUTTON 增加一个事件侦听函数 click_jbutton(e);

解决方案 »

  1.   

    jbutton.addActionListener(new ActionListener()   //为你的JBUTTON注册一个监听器
        {
          public void actionPerformed(ActionEvent e)  //监听程序的内容
          {
            click_jbutton(e);                      //当鼠标按下
          }
        }
      

  2.   


    addActionListener后的一长串东西是一个匿名类,这个匿名类implements了ActionListener分开来写
    // MyActionListener
    class MyActionListener implements ActionListener
    {
          public void actionPerformed(ActionEvent e)
          {
            click_jbutton(e);                  
          }
    }jbutton.addActionListener(new MyActionListener());