Recently I needed to find out the resolution of the monitor that is displaying my Eclipse RCP application, while I had two monitors in use.
In SWT, this can easily be done using org.eclipse.swt.widgets.Monitor.getBounds()
, which canbe utilized in a multi-monitor setup as follows.
Monitor[] monitors = getShell().getDisplay().getMonitors(); Monitor activeMonitor = null; Rectangle r = getShell().getBounds(); for (int i = 0; i < monitors.length; i++) { if (monitors[i].getBounds().intersects(r)) { activeMonitor = monitors[i]; } } System.out.println("The resolution of the active monitor is " + activeMonitor.getBounds().width + " x " + activeMonitor.getBounds().height);
If you found this post helpful, you may want to consider donating to help cover server costs. /td> |
Leave a Comment