If two classes implement ActionListener (say), whose actionPerformed will be invoked?

Prev      Next

Answer: The one whose Component object is "in focus"

Listeners subclass Components. Components have a property known as focus. Focus can be set in any number of ways. If the component is a JFrame just clicking on it will set its focus. There are additional ways to set focus (Tab, Shift-Tab etc.) but these have to be taken care of in a special way. You might want to explore the Java documentation to find out how. Anyway, the component that receives the Event is the one that is in focus.