void (MouseEvent e) { if (myInitialPress == null) { return; } Point location = myPopup.getLocationOnScreen(); myPopup.setLocation(new Point(location.x + e.getX() - myInitialPress.x, location.y + e.getY() - myInitialPress.y)); e.consume(); }