public void mouseDragged(MouseEvent e) { Point p = dlg.getLocationOnScreen(); dlg.setLocation(p.x + e.getX() - origin.x, p.y + e.getY() - origin.y); }