Java listener must inherit from java.util.EventLis

2020-07-06 07:19发布

问题:

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?

回答1:

Probably used by javabeans introspection.

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



回答2:

It’s only important if you want to use an EventListenerList or an EventListenerProxy. I like to use it on my own event listener interfaces as well, though. It makes the purpose of the interface much clearer.