1 | Two ways: write the event listener class, implementing all method names or |
2 | Subclass an adapter class. For each interface that has more than one method, java.awt.event provides an adapter class. This is a class that implements the interface by implementing all method names with an empty body (ignoring event). If you wish to only handle some event types and not others, you can subclass the adapter class and override only those methods used in your application. |
3 | Then your code (applet or application) will create an instance of your event listener class and register it with the event source by calling the addXListener method of the component generating the event. |