If you search these fora, you will find differing opinions, some people favouring anonymous classes, others disliking them. Fortunately there are few people who recommend "addActionListener(this);"
I am one of those hwo like anonymous inner classes, but have a little rule of thumb:- If your Listener does something completely different from all the other Listeners, then anonymous is easiest to code. Keep the code in the actionPerformed() method short; it might be better to call a method elsewhere in the class than to have a long actionPerformed() method.
If you have two Listeners which do the same thing, or several similar things, then you are better off with a named Listener class.
But I think the actionPerformed method with banks of if elses in is an abomination against good programming.
Originally posted by Krishnamurthy Dara: Hope there is no much difference in Perfomance also..
The difference should be at an order of magnitude of nano- to micro-seconds.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus