Adapter Classes In JAVA

Hey tech readers, welcome to our blog. Today I Will be explaining about Adapter Classes in Java.

Now you might be having a number of questions in your mind…What are Adapter classes..? Where they are used..? How they are used….? And so on…

Don’t worry I will be answering all these questions.

Let’s get started,

This class provides the default modification of all methods of an interface, because of this we don’t need to modify all the methods of the interface. It also reduces the burden of writing complex code☺. These are found in java.awt.event, java.awt.dnd and javax.swing.event packages.

There are different kinds of adapter classes which are as follows:-

  • java.awt.event Adapter classes

  1. WindowAdapter
  2. WindowAdapter
  3. KeyAdapter
  4. MouseAdapter
  5. MouseMotionAdapter
  6. FocusAdapter
  7. ComponentAdapter
  8. ContainerAdapter
  9. Hierarchy Bounds Adapter
  • java.awt.dnd Adapter classes

  1. DragSource Adapter
  2. DragTargetAdapter
  • javax.swing.event Adapter classes

  1. MouseInputAdapter
  2. Internal Frame Adapter

Following is one of the example showing usage of Adapters

Java WindowAdapter Example

Adapter classes

Output:- Adapter classes

I hope you guys surely must have learnt something about Adapter classes now and also you enjoyed reading it.

Wish to see you guys in our next blog.  

Happy Learning !!

Leave a Reply

Your email address will not be published. Required fields are marked *