void (MouseEvent e) { var myComponent = this.myComponent.get(); Point p = e.getLocationOnScreen(); Point screen = myComponent.getLocationOnScreen(); if (new Rectangle(screen.x - 4, screen.y - 2, myComponent.getWidth() + 4, myComponent.getHeight() + 4).contains(p)) { mouseEntered(); wasExited = false; } else { if (!wasExited) { wasExited = mouseExited(p); } } }