2011-04-09 57 views
0

公共无效的actionPerformed(ActionEvent的ActionEvent的){ }传递一个对象到一个方法?

是什么线意味着详细地,除了该动作事件的参考被传递给actionPerformed方法。

+1

你能澄清这个问题吗?你的头衔似乎暗示它是关于你说的一件事*在文本中不是*(通过引用)。 – 2011-04-09 05:27:12

回答

8
public void actionPerformed(ActionEvent actionEvent) { } 
  • public:方法是从任何代码访问。
  • void:方法不返回任何东西。
  • actionPerformed:方法的名称。
  • (:您开始指定参数列表。
  • ActionEvent:参数#1的类型。
  • actionEvent:参数#1的名称。
  • ):您已完成指定参数列表。
  • { }:方法没有做任何事情。
4

此方法是ActionListener接口的一部分。

public class Listener implements ActionListener{ 

public static void main(String[] args) { 
    Listener listener = new Listener(); 
    Button button = new Button(); 
    button.addActionListener(listener); 
} 

public void actionPerformed(ActionEvent e) { 
    throw new UnsupportedOperationException("Not supported yet."); 
} 

}

当用户将按下按钮,Listener类的的actionPerformed该方法将被调用。

相关问题