D
Dery
Unregistered / Unconfirmed
GUEST, unregistred user!
在jdk的文档中有这么一段代码
public myComponent extends Component {
ActionListener actionListener = null;
public synchronized void addActionListener(ActionListener l) {
actionListener = AWTEventMulticaster.add(actionListener, l);
}
public synchronized void removeActionListener(ActionListener l) {
actionListener = AWTEventMulticaster.remove(actionListener, l);
}
public void processEvent(AWTEvent e) {
// when event occurs which causes "action" semantic
if (actionListener != null) {
actionListener.actionPerformed(new ActionEvent());
}
}
我在看别人的代码,比如有人自己写的从Componnet派生出来的Button类中就有这么一段
我大概知道作用好像是把监听器挂到新的组件类中去,但我对
actionListener = AWTEventMulticaster.add(actionListener, l);这句的参数不太明白
为什么还有actionListener既是输入参数也是输出参数?
这个函数的意义谁能说得具体,清楚一些?
public myComponent extends Component {
ActionListener actionListener = null;
public synchronized void addActionListener(ActionListener l) {
actionListener = AWTEventMulticaster.add(actionListener, l);
}
public synchronized void removeActionListener(ActionListener l) {
actionListener = AWTEventMulticaster.remove(actionListener, l);
}
public void processEvent(AWTEvent e) {
// when event occurs which causes "action" semantic
if (actionListener != null) {
actionListener.actionPerformed(new ActionEvent());
}
}
我在看别人的代码,比如有人自己写的从Componnet派生出来的Button类中就有这么一段
我大概知道作用好像是把监听器挂到新的组件类中去,但我对
actionListener = AWTEventMulticaster.add(actionListener, l);这句的参数不太明白
为什么还有actionListener既是输入参数也是输出参数?
这个函数的意义谁能说得具体,清楚一些?