Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java listener must inherit from java.util.EventListener - why?

In the javadoc it says that EventListener is

"A tagging interface that all event listener interfaces must extend."

Why is that? What's the significance of making a custom listener implement EventListner? Is there any special handling for EventListner somewhere?

like image 752
Ran Biron Avatar asked Dec 16 '08 11:12

Ran Biron


People also ask

What is Java Util EventListener?

java. util. EventListener is a marker interface(an interface without any methods) that all listeners should implement. In fact, it does not even add any functionality but it may be helpful with some IDEs and code-analysis tools.

Why do we need listeners in Java?

An event listener in Java is designed to process some kind of event — it "listens" for an event, such as a user's mouse click or a key press, and then it responds accordingly. An event listener must be connected to an event object that defines the event.

What is the difference between event and listener in Java?

An EventListener interface defines the methods that must be implemented by an event handler for a particular kind of an event whereas an Event Adapter class provides a default implementation of an EventListener interface.


1 Answers

Probably used by javabeans introspection.

For instance Netbeans beaninfo editor does not recognise the event if extends EventListener is missing from the Listener.

like image 195
asalamon74 Avatar answered Oct 27 '22 00:10

asalamon74