SlideShare a Scribd company logo
1 of 8
JAVA
Adapter class
Prepared by
Miss. Arati A. Gadgil
2
Adapter class
It is one which contains null body definition for those methods which
are inheriting from appropriate Listener.
In java.awt.event.* we have Listener interface called WidowListener
which contains seven abstract methods. In the derived class implements
WindowListener interface; it is mandatory for derived class to define all
the methods even though the derived class is not required.
If the derived class wants to define the required methods, it has to
extend its corresponding adapter class called
java.awt.event.WindowAdapter and this class contains null body
definition for WindowListener interface methods.
Therefore which our Listener interface contains more than one
undefined method for that
Listener interfaces we have the appropriate adapter class whose general
notation is XXXAdapter.
public interface WindowListener
{
void windowActivated(WindowEvent e);
void windowClosed(WindowEvent e);
void windowClosing(WindowEvent e);
void windowDeactivated(WindowEvent e);
void windowDeiconified(WindowEvent e);
void windowIconified(WindowEvent e);
void windowOpened(WindowEvent e);
}
When implementing interface compulsory override all
methods.
3
Adapters are abstract classes for receiving various events. The
methods in these classes are empty. These classes exists as
convenience for creating listener objects.
4
import java.awt.*; import java.awt.event.*;
class frm12 extends Frame implements WindowListener
{ frm12()
{ super("window Listener");
addWindowListener(this);
setSize(300,300);
setVisible(true); }
public void windowActivated(WindowEvent e) { }
public void windowDeactivated(WindowEvent e) { }
public void windowIconified(WindowEvent e) { }
public void windowDeiconified(WindowEvent e) { }
public void windowOpened(WindowEvent e) { }
public void windowClosed(WindowEvent e) { }
public void windowClosing(WindowEvent e){System.exit(0);}
}
public static void main(String []a)
{ frm12 k=new frm12(); }
}
5
import java.awt.*;
import java.awt.event.*;
class wadptor extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
WindowListener wl=new wadptor();
Frame.addWindowListener(listener);
6
frame.addWindowListener(new wadptor());
frame.addWindowListener(new
WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
);
7
Thank You
8

More Related Content

What's hot

Java exception handling
Java exception handlingJava exception handling
Java exception handling
BHUVIJAYAVELU
 
class and objects
class and objectsclass and objects
class and objects
Payel Guria
 
Looping statements in Java
Looping statements in JavaLooping statements in Java
Looping statements in Java
Jin Castor
 

What's hot (20)

Simple Java Programs
Simple Java ProgramsSimple Java Programs
Simple Java Programs
 
Type casting in java
Type casting in javaType casting in java
Type casting in java
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVAMULTI THREADING IN JAVA
MULTI THREADING IN JAVA
 
Methods in Java
Methods in JavaMethods in Java
Methods in Java
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
 
Java swing
Java swingJava swing
Java swing
 
Java exception handling
Java exception handlingJava exception handling
Java exception handling
 
JAVA OOP
JAVA OOPJAVA OOP
JAVA OOP
 
Inheritance and interface
Inheritance and interfaceInheritance and interface
Inheritance and interface
 
class and objects
class and objectsclass and objects
class and objects
 
Classes objects in java
Classes objects in javaClasses objects in java
Classes objects in java
 
Enumeration in Java Explained | Java Tutorial | Edureka
Enumeration in Java Explained | Java Tutorial | EdurekaEnumeration in Java Explained | Java Tutorial | Edureka
Enumeration in Java Explained | Java Tutorial | Edureka
 
Looping statements in Java
Looping statements in JavaLooping statements in Java
Looping statements in Java
 
Java interfaces & abstract classes
Java interfaces & abstract classesJava interfaces & abstract classes
Java interfaces & abstract classes
 
Interface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar SinghInterface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar Singh
 
Operators in java
Operators in javaOperators in java
Operators in java
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
 
Java I/O
Java I/OJava I/O
Java I/O
 
Introduction to method overloading & method overriding in java hdm
Introduction to method overloading & method overriding  in java  hdmIntroduction to method overloading & method overriding  in java  hdm
Introduction to method overloading & method overriding in java hdm
 
WHAT IS ABSTRACTION IN JAVA
WHAT IS ABSTRACTION IN JAVAWHAT IS ABSTRACTION IN JAVA
WHAT IS ABSTRACTION IN JAVA
 

Viewers also liked

Java session13
Java session13Java session13
Java session13
Niit Care
 
Web20 fortgeschrittene 2011_berlin
Web20 fortgeschrittene 2011_berlinWeb20 fortgeschrittene 2011_berlin
Web20 fortgeschrittene 2011_berlin
Jan Schmidt
 
CV Nguyen Huu Mai
CV Nguyen Huu MaiCV Nguyen Huu Mai
CV Nguyen Huu Mai
Mai Nguyen
 

Viewers also liked (17)

Java se 8 streams pt1
Java se 8 streams pt1Java se 8 streams pt1
Java se 8 streams pt1
 
Java session13
Java session13Java session13
Java session13
 
OSHA Cert
OSHA CertOSHA Cert
OSHA Cert
 
Caracteristicas
Caracteristicas Caracteristicas
Caracteristicas
 
Ventajas del Franquiciador y del Franquiciado
Ventajas del Franquiciador y del FranquiciadoVentajas del Franquiciador y del Franquiciado
Ventajas del Franquiciador y del Franquiciado
 
Capitulo3
Capitulo3Capitulo3
Capitulo3
 
Web20 fortgeschrittene 2011_berlin
Web20 fortgeschrittene 2011_berlinWeb20 fortgeschrittene 2011_berlin
Web20 fortgeschrittene 2011_berlin
 
La dignidad y los derechos humanos
La dignidad y los derechos humanosLa dignidad y los derechos humanos
La dignidad y los derechos humanos
 
ISO Lead Auditor Certificate
ISO Lead Auditor CertificateISO Lead Auditor Certificate
ISO Lead Auditor Certificate
 
LOS FRANQUICIADORES COMO FUENTE DE FINANCIAMIENTO
LOS FRANQUICIADORES COMO FUENTE DE FINANCIAMIENTOLOS FRANQUICIADORES COMO FUENTE DE FINANCIAMIENTO
LOS FRANQUICIADORES COMO FUENTE DE FINANCIAMIENTO
 
CV Nguyen Huu Mai
CV Nguyen Huu MaiCV Nguyen Huu Mai
CV Nguyen Huu Mai
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
 
SCM
SCMSCM
SCM
 
Como trabalhar com clientes difíceis e transformá los em clientes satisfeitos
Como trabalhar com clientes difíceis e transformá los em clientes satisfeitosComo trabalhar com clientes difíceis e transformá los em clientes satisfeitos
Como trabalhar com clientes difíceis e transformá los em clientes satisfeitos
 
Fractue fatigue and creep
Fractue fatigue and creepFractue fatigue and creep
Fractue fatigue and creep
 
Bozen Summerschool Digital Libraries
Bozen Summerschool Digital LibrariesBozen Summerschool Digital Libraries
Bozen Summerschool Digital Libraries
 
06.77 JAVA SE_adapter classes
06.77 JAVA SE_adapter classes06.77 JAVA SE_adapter classes
06.77 JAVA SE_adapter classes
 

Similar to Java adapter

java-06inheritance
java-06inheritancejava-06inheritance
java-06inheritance
Arjun Shanka
 
06_OOVP.pptx object oriented and visual programming
06_OOVP.pptx object oriented and visual programming06_OOVP.pptx object oriented and visual programming
06_OOVP.pptx object oriented and visual programming
deffa5
 
SodaPDF-converted-inheritanceinjava-120903114217-phpapp02-converted.pptx
SodaPDF-converted-inheritanceinjava-120903114217-phpapp02-converted.pptxSodaPDF-converted-inheritanceinjava-120903114217-phpapp02-converted.pptx
SodaPDF-converted-inheritanceinjava-120903114217-phpapp02-converted.pptx
RudranilDas11
 
Complete java&j2ee
Complete java&j2eeComplete java&j2ee
Complete java&j2ee
Shiva Cse
 

Similar to Java adapter (20)

Core java questions
Core java questionsCore java questions
Core java questions
 
Interface in java ,multiple inheritance in java, interface implementation
Interface in java ,multiple inheritance in java, interface implementationInterface in java ,multiple inheritance in java, interface implementation
Interface in java ,multiple inheritance in java, interface implementation
 
Interfaces
InterfacesInterfaces
Interfaces
 
Interfaces in java
Interfaces in javaInterfaces in java
Interfaces in java
 
java-06inheritance
java-06inheritancejava-06inheritance
java-06inheritance
 
116824015 java-j2 ee
116824015 java-j2 ee116824015 java-j2 ee
116824015 java-j2 ee
 
Structural pattern 3
Structural pattern 3Structural pattern 3
Structural pattern 3
 
06_OOVP.pptx object oriented and visual programming
06_OOVP.pptx object oriented and visual programming06_OOVP.pptx object oriented and visual programming
06_OOVP.pptx object oriented and visual programming
 
The smartpath information systems java
The smartpath information systems javaThe smartpath information systems java
The smartpath information systems java
 
ch4 foohggggvvbbhhhhhhhhhbbbbbbbbbbbbp.pdf
ch4 foohggggvvbbhhhhhhhhhbbbbbbbbbbbbp.pdfch4 foohggggvvbbhhhhhhhhhbbbbbbbbbbbbp.pdf
ch4 foohggggvvbbhhhhhhhhhbbbbbbbbbbbbp.pdf
 
Java 06
Java 06Java 06
Java 06
 
Java interview questions
Java interview questionsJava interview questions
Java interview questions
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
 
SodaPDF-converted-inheritanceinjava-120903114217-phpapp02-converted.pptx
SodaPDF-converted-inheritanceinjava-120903114217-phpapp02-converted.pptxSodaPDF-converted-inheritanceinjava-120903114217-phpapp02-converted.pptx
SodaPDF-converted-inheritanceinjava-120903114217-phpapp02-converted.pptx
 
Interface
InterfaceInterface
Interface
 
Master of Computer Application (MCA) – Semester 4 MC0078
Master of Computer Application (MCA) – Semester 4  MC0078Master of Computer Application (MCA) – Semester 4  MC0078
Master of Computer Application (MCA) – Semester 4 MC0078
 
Java interface
Java interface Java interface
Java interface
 
Java Core Parctical
Java Core ParcticalJava Core Parctical
Java Core Parctical
 
Complete java&j2ee
Complete java&j2eeComplete java&j2ee
Complete java&j2ee
 
What is an interface How is extending a class different from implem.pdf
What is an interface How is extending a class different from implem.pdfWhat is an interface How is extending a class different from implem.pdf
What is an interface How is extending a class different from implem.pdf
 

More from Arati Gadgil

More from Arati Gadgil (16)

Java swing
Java swingJava swing
Java swing
 
Java applet
Java appletJava applet
Java applet
 
Java layoutmanager
Java layoutmanagerJava layoutmanager
Java layoutmanager
 
Java awt
Java awtJava awt
Java awt
 
Java stream
Java streamJava stream
Java stream
 
Java thread
Java threadJava thread
Java thread
 
Java networking
Java networkingJava networking
Java networking
 
Java jdbc
Java jdbcJava jdbc
Java jdbc
 
Java package
Java packageJava package
Java package
 
Java interface
Java interfaceJava interface
Java interface
 
Java inheritance
Java inheritanceJava inheritance
Java inheritance
 
Java eventhandling
Java eventhandlingJava eventhandling
Java eventhandling
 
Java exception
Java exception Java exception
Java exception
 
Java collection
Java collectionJava collection
Java collection
 
Java class
Java classJava class
Java class
 
Java basic
Java basicJava basic
Java basic
 

Recently uploaded

Recently uploaded (20)

Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 

Java adapter

  • 2. 2 Adapter class It is one which contains null body definition for those methods which are inheriting from appropriate Listener. In java.awt.event.* we have Listener interface called WidowListener which contains seven abstract methods. In the derived class implements WindowListener interface; it is mandatory for derived class to define all the methods even though the derived class is not required. If the derived class wants to define the required methods, it has to extend its corresponding adapter class called java.awt.event.WindowAdapter and this class contains null body definition for WindowListener interface methods. Therefore which our Listener interface contains more than one undefined method for that Listener interfaces we have the appropriate adapter class whose general notation is XXXAdapter.
  • 3. public interface WindowListener { void windowActivated(WindowEvent e); void windowClosed(WindowEvent e); void windowClosing(WindowEvent e); void windowDeactivated(WindowEvent e); void windowDeiconified(WindowEvent e); void windowIconified(WindowEvent e); void windowOpened(WindowEvent e); } When implementing interface compulsory override all methods. 3
  • 4. Adapters are abstract classes for receiving various events. The methods in these classes are empty. These classes exists as convenience for creating listener objects. 4
  • 5. import java.awt.*; import java.awt.event.*; class frm12 extends Frame implements WindowListener { frm12() { super("window Listener"); addWindowListener(this); setSize(300,300); setVisible(true); } public void windowActivated(WindowEvent e) { } public void windowDeactivated(WindowEvent e) { } public void windowIconified(WindowEvent e) { } public void windowDeiconified(WindowEvent e) { } public void windowOpened(WindowEvent e) { } public void windowClosed(WindowEvent e) { } public void windowClosing(WindowEvent e){System.exit(0);} } public static void main(String []a) { frm12 k=new frm12(); } } 5
  • 6. import java.awt.*; import java.awt.event.*; class wadptor extends WindowAdapter { public void windowClosing(WindowEvent e) { System.exit(0); } } WindowListener wl=new wadptor(); Frame.addWindowListener(listener); 6