A
Adam
.... what is it for?
After reading the javadocs I'm a bit confused.
It says:
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());
}
}
So calling actionListener.actionPerformed(...) in processEvent
will notify all ActionListeners added through addActionListener?
I always thought that addXXXListener puts its parameter in some array
or vector, and during processXXXEvent this array
is iterated and actionPerformed is called at all its elements.
Can someone explain how does Multicaster implement that?
Another thing I'm wondering about is enableEvents(...) method.
processXXXEvent shall not be called unless enableEvents with
appropriate flag was called or some corresponding
XXXListener was registered.
How is this implemented in AWT? I mean it probably is some simple
'if' statement, but where is that code? Where do processXXXEvent
methods get called from?
Adam
After reading the javadocs I'm a bit confused.
It says:
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());
}
}
So calling actionListener.actionPerformed(...) in processEvent
will notify all ActionListeners added through addActionListener?
I always thought that addXXXListener puts its parameter in some array
or vector, and during processXXXEvent this array
is iterated and actionPerformed is called at all its elements.
Can someone explain how does Multicaster implement that?
Another thing I'm wondering about is enableEvents(...) method.
processXXXEvent shall not be called unless enableEvents with
appropriate flag was called or some corresponding
XXXListener was registered.
How is this implemented in AWT? I mean it probably is some simple
'if' statement, but where is that code? Where do processXXXEvent
methods get called from?
Adam