Registering Java swing with event types

In Java swing, I can register a listener to a GUI event, as shown below

guiElement.addMouseListener(myListener);

But what if I want to automatically register all mouse events in a GUI application? Should I register my listener with each element? In other words, I'm looking for something similar

myListener.registerToEventType(MouseEvent.class)

Any ideas? thank you

Solution

@See awteventlistener, and mouse & key events

Yes, it is better to use or use swing utilities to apply mouseevents to ridiculed jcomponents, and the notification code may be longer than the anonymous listener added to each jcomponents alone

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>