Adaptor class

Adaptor class
  • The adaptor classes are very special classes that are used to make event handling.
  •  There are listener interfaces that have many methods for event handling.
  • By implementing an interface we have to implement all the methods of that interface.
  •  By sometimes we need only one or some methods of the interface.
  • In that case we use adaptor class.
  • For example, the MouseListener interface has five methods mouseClicked(), mouseEntered(), mouseExited(), mousePressed() and mouseReleased().
  • If in your program you just need two events but you implement five methods of interface.
  • So you can use the adaptor class.
  • The adaptor class contain an empty implementation for each method of the event listener interface.

No comments:

Post a Comment