Doesn't this cause a memory leak because now you cannot remove the action listener when the attacher is getting collected?
this.btnClickMe.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
textArea.append("Hello\n");
}
});
Wouldn't it instead be better to do this?
this.clickMeButtonActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
textArea.append("Hello\n");
}
};
this.btnClickMe.addActionListener(this.clickMeButtonActionListener);
...
@Override
public void dispose() {
this.btnClickMe.removeActionListener(
this.clickMeButtonActionListener);
super.dispose();
}