我正在尝试将方法作为参数传递。怎么做?
我有这个想法:
public class MyButton extends JButton{
public MyButton(){
super();
}
public void setClick( method() );
{
this.addMouseListener(new MouseListener() {
public void mouseClicked(MouseEvent arg0) {
method();
}
public void mouseEntered(MouseEvent arg0) {}
public void mouseExited(MouseEvent arg0) {}
public void mousePressed(MouseEvent arg0) {}
public void mouseReleased(MouseEvent arg0) {}
});
}