Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem with multiple JPanels and handling mouse events

843804Apr 4 2005 — edited Mar 2 2007
Hello 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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 30 2007
Added on Apr 4 2005
7 comments
1,022 views