Adapter Classes
As explained in Chapter 6, "Interfaces," a class that is declared as implementing an interface must implement all the methods declared by that interface. For an ActionListener, this is pretty simple, because the ActionListener interface defines only one method:
public void actionPerformed(ActionEvent e)
For other interfaces, however, that's not the case. For example, every GUI application should have a WindowListener. The WindowListener interface has several methods declared in it, most of which are not necessary for most programs. In order to implement this interface, you might have to create an event-listener class that has several empty methods, like the one shown here:
public void windowClosed(WindowEvente) { }
In order ...
Get PURE Java™ 2 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.