A disclaimer
I wrote the code the way that I did in Listings 8
- to
illustrate an anonymous class that implements an interface.
In real life,
instead of implementing the MouseListener interface, I would probably cause the anonymous class to
- Extend the MouseAdapter class, and
- Override the mouseClicked method
That would eliminate the requirement for me to define the four empty methods in
Listings 8.