If I implement an action event on a JFrame that has some buttons it give me
the button clicked via getSource but if I implement on the same frame a mouse event
it doesn't rise me the event for the buttons but only for that JFrame.
Why?
The event bubbling seems to work only for action event so what model Swing implements?
Which listeners types works in a bubbling way?
Event bubbling up in AWT only works for mouse events, and then only if there are no mouse listeners on the child component.
This can be quite confusing if you have, say, a JComboBox which is typically implemented by the PL&F with a text field and a button component. You might want to look up "glass panes".
I suggest ignoring containment hierarchy as much as possible. Also create listeners that know their context and dot use getSource. And don't extend classes (such as JFrame, JPanel and Thread) unnecessarily.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With