Problem with multiple JPanels and handling mouse events
843804Apr 4 2005 — edited Mar 2 2007Hello all,
I have the following situation:
-- I have two JPanels, one is the "parent" JPanel that represents a large rectangle, and there is an inner "child" JPanel that represents a smaller rectangle.
-- I have a MouseListener for both JPanels.
My current problem is that when the mouse enters the parent JPanel, I get a mouse enter event. However, as soon as you move the mouse inside of the small child JPanel, you get a mouse exit event for the outer JPanel. This is not the behavior that I want. I would like to have Swing NOT generate a mouse exit event when I move the mouse into the inner JPanel, however I would still like the mouse enter event to be generated for the inner JPanel. In other words, I only want to receive a mouse exit event when the mouse leaves the outer JPanel.
Does anyone have any ideas of how I could achieve this? Is there some setting that I have to use when I add the inner JPanel as a child component of the outer parent JPanel?
Any help is appreciated..
Thank you,
-- Ryan