Which are, for every of the following methodology to implement an interface listeners, the pros and cons:
1) into the main class as:
class MyClass implements ActionListener {
public void actionPerformed(ActionEvent e) {
// ...
}
component.addActionListener(this);
}
2) as an inner class as
class MyClass {
private class MyActionListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
// ...
}
}
MyActionListener mal = new MyActionListener();
component.addActionListener(mal);
}
3) as an anonymous inner class as
class MyClass {
component.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// ...
}
});
}