Answer:

Yes. The system does not know which events will be ignored, so it creates an Event object for each one.

ActionListener

A button listener class must implement the ActionListener interface. ActionListener is an interface (not a class) that contains the single method:

public void actionPerformed( ActionEvent evt) ;

The ActionEvent parameter is an Event object that represents an event (a button click). It contains information that can be used in responding to the event. Since ActionListener is an interface, you use it with a class that will implement the actionPerformed() method. It is common to implement the interface in the same class that contains the button(s):

class ButtonFrame extends JFrame implements ActionListener
{
  JButton bChange;

  ButtonFrame()     
  {
     . . . . . .
  }

  
  // listener method for the ActionListener interface
  public void actionPerformed( ActionEvent evt)
  {
     . . . . . .
  }

}

The listener object could be defined in a class separate from the frame class. Large projects probably do this. In our example, the same class that holds the component is also the listener for its events.

QUESTION 12:

Our revised class ButtonFrame says that it implements ActionListener. What does this mean?