(Thought Question: ) Does the Java system create an event object everytime the user interacts with a component?
Yes—the system does not know which events will be ignored, so must create an event object for each one. GUI programs are computationally intense.
A WindowAdapter
object is an
event listener for window (ie. frame) events.
The class has listener methods for
every frame event.
By default, these listener methods receive the event
but then do nothing.
To create a listener for a frame object do this:
WindowAdapter
to create a child class for your special purpose.WindowAdapter
for each type of event you want
to respond to.new
to construct a listener object.addWindowListener()
to register the listener with the frame.
Registering a listener with a frame means connecting the two
objects so that events from one object (the frame) are sent to the
other (the listener).
This is done with the addWindowListener()
method.