Java Code Examples for org.eclipse.swt.widgets.Display#getPrimaryMonitor()
The following examples show how to use
org.eclipse.swt.widgets.Display#getPrimaryMonitor() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SWTUtil.java From SWET with MIT License | 6 votes |
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(); }
Example 2
Source File: ScrolledTextEx.java From SWET with MIT License | 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; }
Example 3
Source File: Main.java From arx with Apache License 2.0 | 5 votes |
/** * 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(); }