Component parent = frame.getContentPane();
Component parent = frame.getLayeredPane();
    private void acquireComponentForMouseEvent(MouseEvent me)    {      int x = me.getX();      int y = me.getY();      // Find the candidate which should receive this event.      Component parent = frame.getContentPane();      if (parent == null)        return;      Component candidate = null;      Point p = me.getPoint();      while (candidate == null && parent != null)        {          candidate = SwingUtilities.getDeepestComponentAt(parent, p.x, p.y);          if (candidate == null)            {              p = SwingUtilities.convertPoint(parent, p.x, p.y,                                              parent.getParent());              parent = parent.getParent();            }        }      // If the only candidate we found was the native container itself,      // don't dispatch any event at all. We only care about the lightweight      // children here.      if (candidate == frame.getContentPane())        candidate = null;      // If our candidate is new, inform the old target we're leaving.      if (lastComponentEntered != null && lastComponentEntered.isShowing()          && lastComponentEntered != candidate)        {          Point tp = SwingUtilities.convertPoint(frame.getContentPane(), x, y,                                                 lastComponentEntered);          MouseEvent exited = new MouseEvent(lastComponentEntered,                                             MouseEvent.MOUSE_EXITED,                                             me.getWhen(), me.getModifiersEx(),                                             tp.x, tp.y, me.getClickCount(),                                             me.isPopupTrigger(),                                             me.getButton());          tempComponent = lastComponentEntered;          lastComponentEntered = null;          tempComponent.dispatchEvent(exited);        }      // If we have a candidate, maybe enter it.      if (candidate != null)        {          mouseEventTarget = candidate;          if (candidate.isLightweight() && candidate.isShowing()              && candidate != frame.getContentPane()              && candidate != lastComponentEntered)            {              lastComponentEntered = mouseEventTarget;              Point cp = SwingUtilities.convertPoint(frame.getContentPane(), x,                                                     y, lastComponentEntered);              MouseEvent entered = new MouseEvent(lastComponentEntered,                                                  MouseEvent.MOUSE_ENTERED,                                                  me.getWhen(),                                                  me.getModifiersEx(), cp.x,                                                  cp.y, me.getClickCount(),                                                  me.isPopupTrigger(),                                                  me.getButton());              lastComponentEntered.dispatchEvent(entered);            }        }      if (me.getID() == MouseEvent.MOUSE_RELEASED          || me.getID() == MouseEvent.MOUSE_PRESSED && pressCount > 0          || me.getID() == MouseEvent.MOUSE_DRAGGED)        // If any of the following events occur while a button is held down,        // they should be dispatched to the same component to which the        // original MOUSE_PRESSED event was dispatched:        // - MOUSE_RELEASED        // - MOUSE_PRESSED: another button pressed while the first is held down        // - MOUSE_DRAGGED        mouseEventTarget = pressedComponent;      else if (me.getID() == MouseEvent.MOUSE_CLICKED)        {          // Don't dispatch CLICKED events whose target is not the same as the          // target for the original PRESSED event.          if (candidate != pressedComponent)            mouseEventTarget = null;          else if (pressCount == 0)            pressedComponent = null;        }    }