Java Code Examples for org.eclipse.swt.widgets.Display.getPrimaryMonitor()

The following are Jave code examples for showing how to use getPrimaryMonitor() of the org.eclipse.swt.widgets.Display class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: SWET   File: ScrolledTextEx.java   Source Code and License Vote up 5 votes
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;
}