Reputation: 75
In Swing, mouse events are automatically targeted to the deepest component that has mouse listeners. How to target them to the deeper components again while there is a component that has mouse listeners and is added on top of others?
It should be done without setting the component invisible or removing its mouse listeners because it is a transparent JPanel
that should do some works depending on mouse events.
dispatchEvent()
is useful only when the target component is known(i.e. the next deeper component).
Upvotes: 0
Views: 55
Reputation: 324108
dispatchEvent() is useful only when the target component is known(i.e. the next deeper component).
You can use the getParent()
method to get the next deeper comoponent.
You can also use the SwingUtillities.getAncestorOfClass(...)
to find a specific parent class.
Upvotes: 1