Adapter Example
Adapter classes are used in awt for event handling :
Button okButton = new Button(“OK”);
okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
oldFile.renameTo(newFile);
The WindowListener interface declares 7 methods that provide notification about 7 different kinds of events. Often, only one or two of these events are of interest. An adapter class that subclasses WindowAdapter needs to implement only the methods of interest. The rest have empty implementations :
addWindowListener(new WindowAdapter() {
public void windowClosing(WindoEvent e) {