In order to respond to the click of a button, an object must be capable of being notified when the button was clicked. This is achieved by the Button object requiring that any such ‘listener’ provide a method named actionPerformed which can then be called to notify the listening object. Define an interface, ActionListener, with a single void-returning method, actionPerformed that accepts a single parameter of type ActionEvent.

LANGUAGE: JAVA

CHALLENGE:

In order to respond to the click of a button, an object must be capable of being notified when the button was clicked. This is achieved by the Button object requiring that any such ‘listener’ provide a method named actionPerformed which can then be called to notify the listening object. Define an interface, ActionListener, with a single void-returning method, actionPerformed that accepts a single parameter of type ActionEvent.

SOLUTION:

interface ActionListener
{
    public void actionPerformed(ActionEvent e);
}