类org.eclipse.swt.widgets.Monitor源码实例Demo

下面列出了怎么用org.eclipse.swt.widgets.Monitor的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: hop   文件: BaseTransformDialog.java
public static void setSize( Shell shell, int prefWidth, int prefHeight ) {
  PropsUi props = PropsUi.getInstance();

  WindowProperty winprop = props.getScreen( shell.getText() );
  if ( winprop != null ) {
    winprop.setShell( shell, prefWidth, prefHeight );
  } else {
    shell.layout();

    winprop = new WindowProperty( shell.getText(), false, 0, 0, prefWidth, prefHeight );
    winprop.setShell( shell );

    // Now, as this is the first time it gets opened, try to put it in the middle of the screen...
    Rectangle shellBounds = shell.getBounds();
    Monitor monitor = shell.getDisplay().getPrimaryMonitor();
    if ( shell.getParent() != null ) {
      monitor = shell.getParent().getMonitor();
    }
    Rectangle monitorClientArea = monitor.getClientArea();

    int middleX = monitorClientArea.x + ( monitorClientArea.width - shellBounds.width ) / 2;
    int middleY = monitorClientArea.y + ( monitorClientArea.height - shellBounds.height ) / 2;

    shell.setLocation( middleX, middleY );
  }
}
 
源代码2 项目: hop   文件: WindowProperty.java
/**
 * This method is needed in the case where the display has multiple monitors, but they do not form a uniform
 * rectangle. In this case, it is possible for Geometry.moveInside() to not detect that the window is partially or
 * completely clipped. We check to make sure at least the upper left portion of the rectangle is visible to give the
 * user the ability to reposition the dialog in this rare case.
 *
 * @param constrainee
 * @param display
 * @return
 */
private boolean isClippedByUnalignedMonitors( Rectangle constrainee, Display display ) {
  boolean isClipped;
  Monitor[] monitors = display.getMonitors();
  if ( monitors.length > 0 ) {
    // Loop searches for a monitor proving false
    isClipped = true;
    for ( Monitor monitor : monitors ) {
      if ( monitor.getClientArea().contains( constrainee.x + 10, constrainee.y + 10 ) ) {
        isClipped = false;
        break;
      }
    }
  } else {
    isClipped = false;
  }

  return isClipped;
}
 
源代码3 项目: n4js   文件: UIUtils.java
/**
 * Given the desired position of the shell, this method returns an adjusted position such that the window is no
 * larger than its monitor, and does not extend beyond the edge of the monitor. This is used for computing the
 * initial window position via the parent shell, clients can use this as a utility method if they want to limit the
 * region in which the window may be moved.
 *
 * @param shell
 *            the shell which shell bounds is being calculated.
 * @param preferredSize
 *            the preferred position of the window.
 * @return a rectangle as close as possible to preferredSize that does not extend outside the monitor.
 */
public static Rectangle getConstrainedShellBounds(final Shell shell, final Point preferredSize) {

	final Point location = getInitialLocation(shell, preferredSize);
	final Rectangle result = new Rectangle(location.x, location.y, preferredSize.x, preferredSize.y);

	final Monitor monitor = getClosestMonitor(shell.getDisplay(), Geometry.centerPoint(result));

	final Rectangle bounds = monitor.getClientArea();

	if (result.height > bounds.height) {
		result.height = bounds.height;
	}

	if (result.width > bounds.width) {
		result.width = bounds.width;
	}

	result.x = Math.max(bounds.x, Math.min(result.x, bounds.x
			+ bounds.width - result.width));
	result.y = Math.max(bounds.y, Math.min(result.y, bounds.y
			+ bounds.height - result.height));

	return result;
}
 
源代码4 项目: n4js   文件: UIUtils.java
/**
 * Returns the initial location to use for the shell. The default implementation centers the shell horizontally (1/2
 * of the difference to the left and 1/2 to the right) and vertically (1/3 above and 2/3 below) relative to the
 * active workbench windows shell, or display bounds if there is no parent shell.
 *
 * @param shell
 *            the shell which initial location has to be calculated.
 * @param initialSize
 *            the initial size of the shell, as returned by <code>getInitialSize</code>.
 * @return the initial location of the shell
 */
public static Point getInitialLocation(final Shell shell, final Point initialSize) {
	final Composite parent = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();

	Monitor monitor = shell.getDisplay().getPrimaryMonitor();
	if (parent != null) {
		monitor = parent.getMonitor();
	}

	final Rectangle monitorBounds = monitor.getClientArea();
	Point centerPoint;
	if (parent != null) {
		centerPoint = Geometry.centerPoint(parent.getBounds());
	} else {
		centerPoint = Geometry.centerPoint(monitorBounds);
	}

	return new Point(centerPoint.x - (initialSize.x / 2), Math.max(
			monitorBounds.y, Math.min(centerPoint.y - (initialSize.y * 2 / 3),
					monitorBounds.y + monitorBounds.height - initialSize.y)));
}
 
源代码5 项目: n4js   文件: UIUtils.java
/**
 * Returns the monitor whose client area contains the given point. If no monitor contains the point, returns the
 * monitor that is closest to the point.
 *
 * @param toSearch
 *            point to find (display coordinates).
 * @param toFind
 *            point to find (display coordinates).
 * @return the monitor closest to the given point.
 */
private static Monitor getClosestMonitor(final Display toSearch, final Point toFind) {
	int closest = Integer.MAX_VALUE;

	final Monitor[] monitors = toSearch.getMonitors();
	Monitor result = monitors[0];

	for (int index = 0; index < monitors.length; index++) {
		final Monitor current = monitors[index];

		final Rectangle clientArea = current.getClientArea();

		if (clientArea.contains(toFind)) {
			return current;
		}

		final int distance = Geometry.distanceSquared(Geometry.centerPoint(clientArea), toFind);
		if (distance < closest) {
			closest = distance;
			result = current;
		}
	}

	return result;
}
 
源代码6 项目: SWET   文件: SWTUtil.java
private static Rectangle getCurrentMonitorBounds(Display dsp) {
	Monitor monitor = dsp.getPrimaryMonitor();

	// Choose current Monitor
	Point cursor = dsp.getCursorLocation();
	Monitor[] monitors = dsp.getMonitors();
	for (Monitor mon : monitors) {
		Rectangle mbounds = mon.getBounds();
		if (mbounds.contains(cursor)) {
			monitor = mon;
			break;
		}
	}

	return monitor.getBounds();
}
 
/**
 * Returns the monitor whose client area contains the given point. If no
 * monitor contains the point, returns the monitor that is closest to the
 * point.
 * <p>
 * Copied from
 * <code>org.eclipse.jface.window.Window.getClosestMonitor(Display, Point)</code>
 * </p>
 * 
 * @param display the display showing the monitors
 * @param point point to find (display coordinates)
 * @return the monitor closest to the given point
 */
private static Monitor getClosestMonitor(Display display, Point point) {
  int closest = Integer.MAX_VALUE;

  Monitor[] monitors = display.getMonitors();
  Monitor result = monitors[0];

  for (int i = 0; i < monitors.length; i++) {
    Monitor current = monitors[i];

    Rectangle clientArea = current.getClientArea();

    if (clientArea.contains(point))
      return current;

    int distance = Geometry.distanceSquared(Geometry.centerPoint(clientArea),
        point);
    if (distance < closest) {
      closest = distance;
      result = current;
    }
  }

  return result;
}
 
源代码8 项目: gama   文件: WorkbenchHelper.java
public static Shell obtainFullScreenShell(final int id) {
	final Monitor[] monitors = WorkbenchHelper.getDisplay().getMonitors();
	int monitorId = id;
	if (monitorId < 0) {
		monitorId = 0;
	}
	if (monitorId > monitors.length - 1) {
		monitorId = monitors.length - 1;
	}
	final Rectangle bounds = monitors[monitorId].getBounds();

	final Shell fullScreenShell = new Shell(WorkbenchHelper.getDisplay(), SWT.NO_TRIM | SWT.ON_TOP);
	fullScreenShell.setBounds(bounds);
	final FillLayout fl = new FillLayout();
	fl.marginHeight = 0;
	fl.marginWidth = 0;
	fl.spacing = 0;
	// final GridLayout gl = new GridLayout(1, true);
	// gl.horizontalSpacing = 0;
	// gl.marginHeight = 0;
	// gl.marginWidth = 0;
	// gl.verticalSpacing = 0;
	fullScreenShell.setLayout(fl);
	return fullScreenShell;
}
 
源代码9 项目: gama   文件: GamlSearchField.java
/**
 * This method was copy/pasted from JFace.
 */
private static Monitor getClosestMonitor(final Display toSearch, final Point toFind) {
	int closest = Integer.MAX_VALUE;

	final Monitor[] monitors = toSearch.getMonitors();
	Monitor result = monitors[0];

	for (final Monitor current : monitors) {
		final Rectangle clientArea = current.getClientArea();

		if (clientArea.contains(toFind)) { return current; }

		final int distance = Geometry.distanceSquared(Geometry.centerPoint(clientArea), toFind);
		if (distance < closest) {
			closest = distance;
			result = current;
		}
	}

	return result;
}
 
源代码10 项目: gama   文件: GamlSearchField.java
/**
 * This method was copy/pasted from JFace.
 */
private Rectangle getConstrainedShellBounds(final Display display, final Rectangle preferredSize) {
	final Rectangle result =
			new Rectangle(preferredSize.x, preferredSize.y, preferredSize.width, preferredSize.height);

	final Point topLeft = new Point(preferredSize.x, preferredSize.y);
	final Monitor mon = getClosestMonitor(display, topLeft);
	final Rectangle bounds = mon.getClientArea();

	if (result.height > bounds.height) {
		result.height = bounds.height;
	}

	if (result.width > bounds.width) {
		result.width = bounds.width;
	}

	result.x = Math.max(bounds.x, Math.min(result.x, bounds.x + bounds.width - result.width));
	result.y = Math.max(bounds.y, Math.min(result.y, bounds.y + bounds.height - result.height));

	return result;
}
 
/**
 * Returns the monitor whose client area contains the given point. If no monitor contains the
 * point, returns the monitor that is closest to the point.
 * <p>
 * Copied from <code>org.eclipse.jface.window.Window.getClosestMonitor(Display, Point)</code>
 * </p>
 *
 * @param display the display showing the monitors
 * @param point point to find (display coordinates)
 * @return the monitor closest to the given point
 */
private static Monitor getClosestMonitor(Display display, Point point) {
	int closest= Integer.MAX_VALUE;

	Monitor[] monitors= display.getMonitors();
	Monitor result= monitors[0];

	for (int i= 0; i < monitors.length; i++) {
		Monitor current= monitors[i];

		Rectangle clientArea= current.getClientArea();

		if (clientArea.contains(point))
			return current;

		int distance= Geometry.distanceSquared(Geometry.centerPoint(clientArea), point);
		if (distance < closest) {
			closest= distance;
			result= current;
		}
	}

	return result;
}
 
源代码12 项目: arx   文件: MainSplash.java
/**
 * Creates a new instance.
 *
 * @param display
 * @param monitor
 */
public MainSplash(Display display, Monitor monitor) {
    
    this.version = ARXAnonymizer.VERSION;
    this.splash = Resources.getSplash(display);
    this.shell = new Shell(SWT.ON_TOP | (isMac() ? 0 : SWT.NO_TRIM));
    this.shell.setImages(Resources.getIconSet(display));
    this.shell.setSize(splash.getBounds().width, splash.getBounds().height);
    
    // Center
    SWTUtil.center(shell, monitor);
    
    // Paint
    shell.addPaintListener(new PaintListener(){
        public void paintControl(PaintEvent arg0) {
            paint(arg0.gc);
        }
    });
}
 
源代码13 项目: pentaho-kettle   文件: DataOverrideHandler.java
private Shell getCenteredShell( Shell shell ) {
  Rectangle shellBounds = shell.getBounds();
  Monitor monitor = shell.getDisplay().getPrimaryMonitor();

  if ( shell.getParent() != null ) {
    monitor = shell.getParent().getMonitor();
  }

  Rectangle monitorClientArea = monitor.getClientArea();

  int middleX = monitorClientArea.x + ( monitorClientArea.width - shellBounds.width ) / 2;
  int middleY = monitorClientArea.y + ( monitorClientArea.height - shellBounds.height ) / 2;

  shell.setLocation( middleX, middleY );

  return shell;
}
 
源代码14 项目: pentaho-kettle   文件: WindowProperty.java
/**
 * This method is needed in the case where the display has multiple monitors, but they do not form a uniform
 * rectangle. In this case, it is possible for Geometry.moveInside() to not detect that the window is partially or
 * completely clipped. We check to make sure at least the upper left portion of the rectangle is visible to give the
 * user the ability to reposition the dialog in this rare case.
 *
 * @param constrainee
 * @param display
 * @return
 */
private boolean isClippedByUnalignedMonitors( Rectangle constrainee, Display display ) {
  boolean isClipped;
  Monitor[] monitors = display.getMonitors();
  if ( monitors.length > 0 ) {
    // Loop searches for a monitor proving false
    isClipped = true;
    for ( Monitor monitor : monitors ) {
      if ( monitor.getClientArea().contains( constrainee.x + 10, constrainee.y + 10 ) ) {
        isClipped = false;
        break;
      }
    }
  } else {
    isClipped = false;
  }

  return isClipped;
}
 
源代码15 项目: hop   文件: BaseTransformDialog.java
/**
 * Sets the size of this dialog with respect to the given parameters.
 *
 * @param shell     the shell
 * @param minWidth  the minimum width
 * @param minHeight the minimum height
 * @param packIt    true to pack the dialog components, false otherwise
 */
public static void setSize( Shell shell, int minWidth, int minHeight, boolean packIt ) {
  PropsUi props = PropsUi.getInstance();

  WindowProperty winprop = props.getScreen( shell.getText() );
  if ( winprop != null ) {
    winprop.setShell( shell, minWidth, minHeight );
  } else {
    if ( packIt ) {
      shell.pack();
    } else {
      shell.layout();
    }

    // OK, sometimes this produces dialogs that are waay too big.
    // Try to limit this a bit, m'kay?
    // Use the same algorithm by cheating :-)
    //
    winprop = new WindowProperty( shell );
    winprop.setShell( shell, minWidth, minHeight );

    // Now, as this is the first time it gets opened, try to put it in the middle of the screen...
    Rectangle shellBounds = shell.getBounds();
    Monitor monitor = shell.getDisplay().getPrimaryMonitor();
    if ( shell.getParent() != null ) {
      monitor = shell.getParent().getMonitor();
    }
    Rectangle monitorClientArea = monitor.getClientArea();

    int middleX = monitorClientArea.x + ( monitorClientArea.width - shellBounds.width ) / 2;
    int middleY = monitorClientArea.y + ( monitorClientArea.height - shellBounds.height ) / 2;

    shell.setLocation( middleX, middleY );
  }
}
 
源代码16 项目: Universal-FE-Randomizer   文件: MainView.java
public MainView(Display mainDisplay) {
	super();
	
	Shell shell = new Shell(mainDisplay, SWT.SHELL_TRIM & ~SWT.MAX); 
	 shell.setText("Yune: A Universal Fire Emblem Randomizer (v0.9.1)");
	 shell.setImage(new Image(mainDisplay, Main.class.getClassLoader().getResourceAsStream("YuneIcon.png")));
	 
	 screenHeight = mainDisplay.getBounds().height;
	 for (Monitor monitor : mainDisplay.getMonitors()) {
		 screenHeight = Math.max(screenHeight, monitor.getClientArea().height);
	 }
	 
	 screenHeight -= 20;
	 
	 mainShell = shell;
	 
	 setupMainShell();
	 
	 resize();
	 
	 /* Open shell window */
	  mainShell.open();
	  
	  mainDisplay.addFilter(SWT.KeyDown, new Listener() {
		@Override
		public void handleEvent(Event event) {
			if (((event.stateMask & SWT.CTRL) != 0) && ((event.stateMask & SWT.SHIFT) != 0) && (event.keyCode == 'c') && !consoleShellOpened) {
				openConsole();
			}
		}
	  });
}
 
源代码17 项目: nebula   文件: SWTGraphicUtil.java
/**
 * Center a shell on the primary monitor
 *
 * @param shell shell to center
 */
public static void centerShell(final Shell shell) {
	final Monitor primary = shell.getDisplay().getPrimaryMonitor();
	final Rectangle bounds = primary.getBounds();
	final Rectangle rect = shell.getBounds();
	final int x = bounds.x + (bounds.width - rect.width) / 2;
	final int y = bounds.y + (bounds.height - rect.height) / 2;
	shell.setLocation(x, y);
}
 
源代码18 项目: nebula   文件: SWTGraphicUtil.java
/**
 * @param shell
 * @return the bounds of the monitor on which the shell is running
 */
public static Rectangle getBoundsOfMonitorOnWhichShellIsDisplayed(final Shell shell) {
	Monitor monitor = shell.getDisplay().getPrimaryMonitor();
	if(shell != null && shell.getMonitor() != null) {
		monitor = shell.getMonitor();
	} 
	
	return monitor.getBounds();
}
 
源代码19 项目: nebula   文件: Utils.java
/**
 * Centers a dialog (Shell) on the <b>primary</b> (active) display.
 * 
 * @param shell Shell to center on screen
 * @see Shell
 */
public static void centerDialogOnScreen(final Shell shell) {
	// do it by monitor to support dual-head cards and still center things correctly onto the screen people are on.
    final Monitor monitor = Display.getDefault().getPrimaryMonitor();
    final Rectangle bounds = monitor.getBounds();

    final int screen_x = bounds.width;
    final int screen_y = bounds.height;

	shell.setLocation(screen_x / 2 - (shell.getBounds().width / 2), screen_y / 2 - (shell.getBounds().height / 2));
}
 
源代码20 项目: SWET   文件: ScrolledTextEx.java
private static Point center(Display display, Shell shell) {
	Monitor primary = display.getPrimaryMonitor();
	Rectangle bounds = primary.getBounds();
	Rectangle rect = shell.getBounds();

	int x = bounds.x + (bounds.width - rect.width) / 2;
	int y = bounds.y + (bounds.height - rect.height) / 2;

	Point location = new Point(x, y);
	return location;
}
 
源代码21 项目: workspacemechanic   文件: AbstractPopup.java
private Monitor selectMonitor(Display display) {
  Shell activeShell = display.getActiveShell();
  if (activeShell != null && activeShell.getMonitor() != null) {
    return activeShell.getMonitor();
  }

  // Fall-back
  Monitor[] monitors = display.getMonitors();
  if (monitors.length > 0) {
    return monitors[0];
  }

  // Worst case. What? Can this happen?
  return null;
}
 
源代码22 项目: workspacemechanic   文件: AbstractPopup.java
private void setPosition(Shell shell) {
  Monitor monitor = selectMonitor(display);
  if (monitor != null) {
    Rectangle clientArea = monitor.getClientArea();
    Point size = shell.getSize();
    int x = (clientArea.x + clientArea.width - size.x) - 2;
    int y = (clientArea.y + clientArea.height - size.y) - 2;
    shell.setLocation(x, y);
  }
}
 
源代码23 项目: statecharts   文件: SelectExamplePage.java
private Rectangle calculatePosition(int scale, int offset) {
	Monitor monitor = getMonitor();
	offset = offset * scale;
	int width = (monitor.getBounds().width + offset) / scale;
	int height = (monitor.getBounds().height + offset) / scale;
	int x = monitor.getBounds().x + (width - offset) / scale;
	int y = monitor.getBounds().y + (height - offset) / scale;
	return new Rectangle(x, y, width, height);
}
 
源代码24 项目: developer-studio   文件: ProjectOptionsDataPage.java
private void setShellLoc(Shell shell) {
	Monitor primary = Display.getCurrent().getPrimaryMonitor();
    Rectangle bounds = primary.getBounds();
    Rectangle rect = shell.getBounds();
    
    int x = bounds.x + (bounds.width - rect.width) / 2;
    int y = bounds.y + (bounds.height - rect.height) / 2;
    
    shell.setLocation(x, y);
	
}
 
源代码25 项目: jframe   文件: JframeApp.java
public void layout2Center() {
    Monitor primary = shell.getDisplay().getPrimaryMonitor();
    Rectangle bounds = primary.getBounds();
    Rectangle rect = shell.getBounds();
    int x = bounds.x + (bounds.width - rect.width) / 2;
    int y = bounds.y + (bounds.height - rect.height) / 2;
    shell.setLocation(x, y);
}
 
源代码26 项目: birt   文件: BreadcrumbItemDropDown.java
/**
 * Returns the monitor whose client area contains the given point. If no
 * monitor contains the point, returns the monitor that is closest to the
 * point.
 * <p>
 * Copied from
 * <code>org.eclipse.jface.window.Window.getClosestMonitor(Display, Point)</code>
 * </p>
 * 
 * @param display
 *            the display showing the monitors
 * @param point
 *            point to find (display coordinates)
 * @return the monitor closest to the given point
 */
private static Monitor getClosestMonitor( Display display, Point point )
{
	int closest = Integer.MAX_VALUE;

	Monitor[] monitors = display.getMonitors( );
	Monitor result = monitors[0];

	for ( int i = 0; i < monitors.length; i++ )
	{
		Monitor current = monitors[i];

		Rectangle clientArea = current.getClientArea( );

		if ( clientArea.contains( point ) )
			return current;

		int distance = Geometry.distanceSquared( Geometry.centerPoint( clientArea ),
				point );
		if ( distance < closest )
		{
			closest = distance;
			result = current;
		}
	}

	return result;
}
 
源代码27 项目: birt   文件: UIHelper.java
/**
 * Center shell on specified monitor.
 * 
 * @param monitor specified monitor will display shell.
 * @param shell the shell to be centered on monitor.
 */
public static void centerOnMonitor( Monitor monitor, Shell shell) {
	
	Rectangle clientArea = monitor.getClientArea();
	shell.setLocation( clientArea.x + ( clientArea.width / 2 ) - ( shell.getSize( ).x / 2 ),
			clientArea.y + ( clientArea.height / 2 ) - ( shell.getSize( ).y / 2 ) );
}
 
源代码28 项目: arx   文件: SWTUtil.java
/**
 * Centers the shell on the given monitor.
 *
 * @param shell
 * @param monitor
 */
public static void center(Shell shell, Monitor monitor) {
    Rectangle shellRect = shell.getBounds();
    Rectangle displayRect = monitor.getBounds();
    int x = (displayRect.width - shellRect.width) / 2;
    int y = (displayRect.height - shellRect.height) / 2;
    shell.setLocation(displayRect.x + x, displayRect.y + y);
}
 
源代码29 项目: arx   文件: Main.java
/**
 * Returns the monitor on which the application was launched.
 *
 * @param display
 * @return
 */
private static Monitor getMonitor(Display display) {
    Point mouse = display.getCursorLocation();
    for (Monitor monitor : display.getMonitors()) {
        if (monitor.getBounds().contains(mouse)) {
            return monitor;
        }
    }
    return display.getPrimaryMonitor();
}
 
源代码30 项目: hop   文件: WindowProperty.java
/**
 * Performs calculations to size and position a dialog If the size passed in is too large for the primary monitor
 * client area, it is shrunk to fit. If the positioning leaves part of the dialog outside the client area, it is
 * centered instead.
 *
 * @param shell        The dialog to position and size
 * @param onlyPosition Unused argument. If the window is outside the viewable client are, it must be resized to prevent
 *                     inaccessibility.
 * @param minWidth
 * @param minHeight
 */
public void setShell( Shell shell, boolean onlyPosition, int minWidth, int minHeight ) {
  shell.setMaximized( maximized );
  shell.setBounds( new Rectangle(x, y, width, height) );

  if ( minWidth > 0 || minHeight > 0 ) {
    Rectangle bounds = shell.getBounds();
    if ( bounds.width < minWidth ) {
      bounds.width = minWidth;
    }
    if ( bounds.height < minHeight ) {
      bounds.height = minHeight;
    }
    shell.setSize( bounds.width, bounds.height );
  }

  // Just to double check: what is the preferred size of this dialog?
  // This computed is a minimum. If the minimum is smaller than the
  // size of the current shell, we make it larger.
  //
  Point computedSize = shell.computeSize( SWT.DEFAULT, SWT.DEFAULT );
  Rectangle shellSize = shell.getBounds();
  if ( shellSize.width < computedSize.x ) {
    shellSize.width = computedSize.x;
  }
  if ( shellSize.height < computedSize.y ) {
    shellSize.height = computedSize.y;
  }
  shell.setBounds( shellSize );

  Rectangle entireClientArea = shell.getDisplay().getClientArea();
  Rectangle resizedRect = Geometry.copy( shellSize );
  constrainRectangleToContainer( resizedRect, entireClientArea );

  // If the persisted size/location doesn't perfectly fit
  // into the entire client area, the persisted settings
  // likely were not meant for this configuration of monitors.
  // Relocate the shell into either the parent monitor or if
  // there is no parent, the primary monitor then center it.
  //
  if ( !resizedRect.equals( shellSize ) || isClippedByUnalignedMonitors( resizedRect, shell.getDisplay() ) ) {
    Monitor monitor = shell.getDisplay().getPrimaryMonitor();
    if ( shell.getParent() != null ) {
      monitor = shell.getParent().getMonitor();
    }
    Rectangle monitorClientArea = monitor.getClientArea();
    constrainRectangleToContainer( resizedRect, monitorClientArea );

    resizedRect.x = monitorClientArea.x + ( monitorClientArea.width - resizedRect.width ) / 2;
    resizedRect.y = monitorClientArea.y + ( monitorClientArea.height - resizedRect.height ) / 2;

    shell.setBounds( resizedRect );
  }
}
 
 类所在包
 同包方法