示例#1
0
  private void processParentWindowMoved() {
    if (isDisposed()) return;

    final Point newOwnerPoint = myOwnerWindow.getLocationOnScreen();

    int deltaX = myLastOwnerPoint.x - newOwnerPoint.x;
    int deltaY = myLastOwnerPoint.y - newOwnerPoint.y;

    myLastOwnerPoint = newOwnerPoint;

    final Window wnd = SwingUtilities.getWindowAncestor(getContent());
    final Point current = wnd.getLocationOnScreen();

    setLocation(new Point(current.x - deltaX, current.y - deltaY));
  }
示例#2
0
 private void registerAutoMove() {
   if (myOwner != null) {
     myOwnerWindow = SwingUtilities.getWindowAncestor(myOwner);
     if (myOwnerWindow != null) {
       myLastOwnerPoint = myOwnerWindow.getLocationOnScreen();
       myOwnerListener = new MyComponentAdapter();
       myOwnerWindow.addComponentListener(myOwnerListener);
     }
   }
 }