AWT Adapters

Some of the interfaces listed in Table 9-3 require implementing a fair number of methods. Listeners, a good percentage of the time, are only interested in implementing a small subset of the methods defined by listener interfaces. For instance, it is common to implement WindowListener.windowClosing() to handle the closing of the window, without any interest in the other six events defined by the WindowListener interface.

To free developers from having to implement every method defined in a listener interface, the AWT provides a number of adapter classes that provide no-op implementations of the methods defined in the appropriate interface. For example, java.awt.event.MouseAdapter implements all of the methods defined in java.awt.event.MouseListener ...

Get Graphic Java™ 1.2, Volume I: AWT, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.