Java监听器必须从java.util.EventListener继承 - 为什么?

时间:2022-05-20 07:00:47

In the javadoc it says that EventListener is

在javadoc中它表示EventListener是

"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?

这是为什么?使自定义侦听器实现EventListner的重要性是什么? EventListner在某处有什么特殊处理吗?

2 个解决方案

#1


5  

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.

如果要使用EventListenerList或EventListenerProxy,这一点非常重要。我喜欢在我自己的事件监听器接口上使用它。它使界面的目的更加清晰。

#2


7  

Probably used by javabeans introspection.

可能由javabeans内省使用。

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

例如,如果监听器中缺少扩展的EventListener,则Netbeans beaninfo编辑器无法识别该事件。

#1


5  

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.

如果要使用EventListenerList或EventListenerProxy,这一点非常重要。我喜欢在我自己的事件监听器接口上使用它。它使界面的目的更加清晰。

#2


7  

Probably used by javabeans introspection.

可能由javabeans内省使用。

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

例如,如果监听器中缺少扩展的EventListener,则Netbeans beaninfo编辑器无法识别该事件。