Introduction to OOP Chapter 22: The AWT and Swing : next previous audio real text

Creating a Listener

The programmer then creates a new class that subclasses the adapter and overrides the methods of interest, then registers an instance of the class with the component.
class MyWindow extends JFrame {
	public MyWindow () {
		...
		addMouseListener (new MouseKeeper());
	}
	...
	private class MouseKeeper extends MouseAdapter {
		public void mousePressed (MouseEvent e) {
			...
		}
	}
}
Inner classes are particularly usefor for this idiom.
Intro OOP, Chapter 22, Slide 08