PilotYid schrieb:
> I am having some trouble with the mouseExited event in
> MouseAdapter/MouseListener. I have a Panel with 3 labels on it. I would
[quoted text clipped - 11 lines]
> Thanks for your help,
> Aaron
You could use the next piece of code to check if the last position is
still inside the boundaries of the panel.
class MyMouseAdapter extends MouseAdapter {
public void mouseExited(MouseEvent e) {
boolean insidePanel = ((JPanel)
e.getSource()).getBounds().inside(e.getX(), e.getY());
if (!insidePanel) {
return;
}
System.out.println("do your stuff here");
}
}
You can only use a glasspane on a JFrame if that is not a problem you
could use that to. If you need to get mouse-motion-events the glasspane
is probably the only valid method.
PilotYid - 07 Feb 2006 23:55 GMT
Thanks, Ill take a look at that. But wouldnt the X and Y always be
inside the Panel,
even if the mouse is leaving the panel boundaries? Or is the X/Y the
coords of the pointer as soon as it leaves? That is, if the mouse is
leaving the panel, what would the X/Y be on mouseExited? the last point
inside the
panel, or the first point outside it?
Thanks
Douwe - 10 Feb 2006 21:34 GMT
Apparently the X and Y are the position outside the rectangle. I wrote
a small test program myself so it shouls work :)