I'll explain in examples.
• Multiple listeners cause unrelated parts of a program to react to the same event;
• All registered listeners call their handlers when the event occurs;
Think you added 3 Action listetens to button. And when button is clicked, all the methods of listenes will be executed.
Button btn = new Button(“OK”
;
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
btn_actionPerformed1(e);}});
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
btn_actionPerformed2(e);}});
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
btn_actionPerformed3(e);}});
When btn button is clicked then, all three functions will be called:
btn_actionPerformed1
btn_actionPerformed2
btn_actionPerformed3
But you can't say in which order they will be called!
That's all.
Jamal