[GUI] How do you get mouse position without getting blocked by JPanels?

Kind of hard to describe it, so I’m going to use art to show you my problem:

Here we have a JComponent named “MainComponent”, with a JPanel added to it. Note that outside of the JPanel, there is a little bit of space that’s part of MainComponent. Which means, JPanel isn’t exactly on the edge of the JComponent.

When I move my mouse across the JComponent from left to right, the MouseMotionListener will stop listening when the mouse is on top of JPanel. I don’t want JPanel to consume the MouseMotionEvent.

How do I make it so that the event isn’t consumed, and that JComponent can still listen to the mouse motion events the whole time, even with JPanel blocking it?