O'Reilly logo
  • Michael ss thinks this is interesting:

Many listener interfaces define several methods that may not be required by your application. However, whenever you implement an interface you must provide the implementation for all its methods (refer to Chapter 6). The designers of the Swing APIs came up with the idea of Adapter classes for event processing, which save you the trouble of implementing the various interface methods. A typical Adapter class implements a certain listener interface and provides empty implementation to all its methods. You simply need to extend your class from the Adapter class and override the desired methods to achieve whatever application functionality your application needs.


Cover of Java Programming


由于一个class要implement一个interface则要实ra现它的全部方法,否则,这个class就是abstract,Sing提供了Adapter classes直接用空方法实现interface,然后自己重写自己要的方法即可