An Example from GUI Event-Handling Interfaces
Let me illustrate interfaces through GUI event handling. An event is basically an action such as clicking a button, selecting a Menu item, or clicking on an item in a List box. The type of event that is generated when you click a Java button object with the mouse is an ActionEvent.
Think of all the Applets and applications written in Java that have an OK or Submit button or the like. No one class, even with hundreds of methods, could provide for all these buttons.
This problem is solved by using an interface for event handling. An interface declares the name of the method to call, but it leaves the implementation of OK-button logic completely open. It also provides for a common method name where ...
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.