Re: Fire mouseExited only when leaving panel boundaries?



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
like to start a timer when the mouse is anywhere over this panel
(including the labels), and stop the timer when it leaves the panel
boundaries. I have added a mouselistener to do this but when moving
internally within the panel from the panel to a label, I am getting a
mouseexited on the Panel which is stopping the timer. Is there anyway
to get around this? I only want to do something upon leaving the Panel
boundaries, not when moving internally within the panel to a label,
etc.
The labels inside the Panel do not have to handle any events.
I have to use Java 1.1 as well. Would some kind of glasspane work here?

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.

.



Relevant Pages

  • Re: Fire mouseExited only when leaving panel boundaries?
    ... I have a Panel with 3 labels on it. ... and stop the timer when it leaves the panel ... public void mouseClicked{ ...
    (comp.lang.java.gui)
  • Re: Dynamic Controls - Still!
    ... I've got another page where the same code works just fine, but the labels ... A panel derives from Control just like the Page ... > Dim ddl As DropDownList = New DropDownList ...
    (microsoft.public.dotnet.framework.aspnet.buildingcontrols)
  • Re: The Electricians Credo, part XXXIV
    ... owns the house know which breaker goes where. ... The NEC requires the panel to be labeled, ... Typically you'll get general labels like first floor lighting, ... The electrician that wired my house made a computer printed label that ...
    (alt.home.repair)
  • Re: performance
    ... >I'm going to create a web form to show some textboxes to users, ... I'm thinking not using 2 pages but use panel ... >server control to group my textboxes and labels, before postback, i ... My questions is hiding a lot of server controls will be ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: VB .NET dynamic number of controls...
    ... > I've been trying todo this by creating arrays of progressbars and labels. ... > progress on, I create a bar and label and add them to a panel. ... no labels, no progress bars. ...
    (microsoft.public.dotnet.general)