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 must
implement the ActionListener interface.
ActionListener is an interface (not a class)
that contains a
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.
ActionListener is an interface.
A class that implements the interface must contain an
actionPerformed() method.
Import the package java.awt.event.*
if you are dealing with events.
import java.awt.*; import java.awt.event.*; import java.awt.*; 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. In our example, the same class that holds the component is also the listener for its events.
QUESTION 10:
Our revised class ButtonFrame says that it
implements ActionListener.
What does this mean?