Guessing: possibly this is a case where extracting the ActionListener
is not a great idea, since it uses a private
method of your object.
Classes with generic/reusable functionality deserve to be on their own. As long as they are intended for specific usage, it's not bad practice (at all!) to only put them as close as possible to the spot where they're used. I can imagine that your setSize
method is not part of your class' public interface, so the ActionListener
is merely 'glue' to couple an event to your specific class.
In this case, you would create a 'tiny' line of glue:
abstract class ActionAdapter implements ActionListener {
}
...
frame.Console_Bouton.addActionListener(
new ActionAdapter(){ // anonymous inner class
void actionPerformed(ActionEvent e){
... // (no need to check source!)
}
});