Its common to use an inner class when adding an ActionEvent to a listener, for example in Swing. This removes the need to conditionally
test what button has been clicked in a function to designate the appropriate action: A quick sketch example would be....
J
The inner class would then extend the relevant abstract classes for action-Events and the overridden method ActionPerformed() will handle the button click. Take a look also on the Swing Forums here at the ranch.