actionPerformed()
actionPerformed()
The parameter for actionPerformed()
is a reference to an ActionEvent
object.
When the button is clicked,
the method is called with a new action object parameter.
So far,
we've not used the
ActionEvent
object.
You will see this shortly.
Here is the picture of what is happening:
Usually the registered ActionListener
is the same object
as the frame that holds the button.
Usually this is an object
that derives from the Swing JFrame
class.
(In other words, you define a class based
on JFrame
.
The class contains a button
and implements the ActionListener
interface).