I have a JPanel (A) which contains another JPanel (B). Each panel implements a MouseMotionListener and a MouseListener. On dragging only the inner/upper panel (B) responds to this event. So I removed the MouseMotionListener from A and the MouseListener from B. The second tests shows that A only responds if the cursor is outside of B.
Is there a solution that both panels react to the same listener. I need the getX()-method of each event. Each panel should return another x-value in the drag-event. So event-forwarding wouldn’t be a solution in my case.
Many thanks…
I don’t believe that Swing provides any support for bubbling of events (meaning an event on one element will not be transmitted to its parent). A workaround for this would be to pass the parent Object to the child and manually call its event handler when the event occurs on the child (not great, but it works).