Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

What is the difference between implementing the event handler using a \"Listener

ID: 3561915 • Letter: W

Question

What is the difference between implementing the event handler using a "Listener" vs. an "Adaptor"?  Choose a unique(i.e., different from classmate's entries) listener type and describe the event that causes the methods of the listener to be invoked. In addition, describe a scenario where that listener type will be used in an application.

The following Java Tutorial link provides information related to listener.

  http://java.sun.com/docs/books/tutorial/uiswing/events/eventsandcomponents.html

Note: No Plagiarism

Explanation / Answer

a)

Listener

Adapter

A Listener is an Interface.

An Adapter is a class.

When a Listener is used in a program, all the        methods in the Listener interface should be overridden.

By using the Adapter class, there will be no need to implement all the methods unnecessarily.

A class has to implement the Listener.

A class has to extends the Adapter

Listener interface increases the content of the program.

Adapter class reduces the clutter of the code.

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

b)

MouseListener:

Mouse is one of the input devices of the computer. Basing on the user

Listener

Adapter

A Listener is an Interface.

An Adapter is a class.

When a Listener is used in a program, all the        methods in the Listener interface should be overridden.

By using the Adapter class, there will be no need to implement all the methods unnecessarily.

A class has to implement the Listener.

A class has to extends the Adapter

Listener interface increases the content of the program.

Adapter class reduces the clutter of the code.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote