Loading
ADAPTER VS LISTENER

Java Quick Notes

Refresh Your Java - Before Java Interview

We are Agile, believe in less Documentation - Only Quick notes (Java Interview Questions) of Java/J2ee Read more....


Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet

Go to SiteMap

Q)  AWT/Swing Adapter VS Listener ?


Ans)


Many listener interfaces have more than one callback method. An example is java.awt.FocusListener
that has two methods; focusGained(java.awt.FocusEvent event) and focusLost(java.awt.FocusEvent event).
When creating a listener class that implements the interface the Java compiler insists that all
of the interface methods are implemented
, which often results in many empty methods being created to
satisfy its requirements when only one or some of its methods actually contain code. The following
statement shows a FocusListener being used to perform some logic when a Java bean gains focus. However,
an empty focusLost method must be provided.

To avoid having many empty listener methods for many listeners, Adapter classes are provided.
These implement the listener interface, and provide empty no-op implementation of its methods. 

 



Back to top

------------------------- We hope you got necessary Info On -----------------------------------------

ADAPTER VS LISTENER


ADAPTER VS LISTENER

-------------------------------------------------------------------------------------------------------



Face Book
Request for a Mock Interview/Training

Get a PDF

Face Book
Same look (Read) on any device, this is Ads free