What is Adapterclass? when do we use it?Please give me the answers.
NOTE : [I][This question was asked by Srivani][/I]
Printable View
What is Adapterclass? when do we use it?Please give me the answers.
NOTE : [I][This question was asked by Srivani][/I]
An adapter is one of the classic design patterns. It is also a class in Java that implements an interface with a set of dummy methods. You can then subclass the adapter class and override just the methods you need. If you implemented the interface directly, you would have to write all the dummy methods yourself. Most commonly an adapter is used to help you rapidly construct your own Listener class to field events. My extending an adapter class, with KeyAdapter, FocusAdapter, WindowAdapter etc. you don't have to write methods for events you are not interested in handling.
An adapter class provides an empty implementation of all the methods in an event listener.U can define a new class to act as an event listener by extending one of the adapter classes an implementing only those events in which u r interested