Best way to implement actionPerformed?
<p>In Java, we have two ways to implement actionPerformed:</p>

<ol>
<li>One actionPerformed method per class: use if-else to check event source;</li>
<li>Use anonymous inner classes and implement the actionPerformed method in where that object is created;</li>
</ol>

<p>For option 1, it is easy to keep track of where the actionPerformed code is because there is only one method per class. We can easy locate that method and then look inside to find the code we are looking for. However, there may be too many if-else clauses if we have many action listeners.</p>

<p>For option 2, it is not easy to find where the actionPerformed code is because it is scattered all over the class. If you have many action listeners, it will be more difficult to keep track of the actionPerformed instances.</p>

<p>I personally prefer option 1 because it is much easier to maintain the code, even the performance may be less efficient than option 2. </p>

<p>What are the pros and cons of each method? What else should be taken into consideration when choosing how to implement actionPerformed? Which way do you prefer?</p>

<p><strong>EDIT:</strong></p>

<p>so there is a 3rd option based on the suggestion from A. Lee below.
it is a combination of the option 1 and option 2: use anonymous inner classes but put them altogether in ONE place within a class. 
I think it is a good idea.</p>
