void (MouseEvent e) { var myComponent = this.myComponent.get(); Component component = e.getComponent(); if (component != null && SwingUtilities.isDescendingFrom(component, SwingUtilities.getWindowAncestor(myComponent))) { int id = e.getID(); if (id == MouseEvent.MOUSE_MOVED && myComponent.isShowing()) { mouseMoved(e); } else if (id == MouseEvent.MOUSE_EXITED) { //mouse exits WND mouseExited(e.getLocationOnScreen()); } } }