Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The answer depends on the definition of screen. Do you want the default screen bounds or a specific screen bounds?</p> <p>I use the following (&amp; variations of it) to determine the screen bounds for an individual screen</p> <pre><code>public static GraphicsDevice getGraphicsDeviceAt(Point pos) { GraphicsDevice device = null; GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice lstGDs[] = ge.getScreenDevices(); ArrayList&lt;GraphicsDevice&gt; lstDevices = new ArrayList&lt;GraphicsDevice&gt;(lstGDs.length); for (GraphicsDevice gd : lstGDs) { GraphicsConfiguration gc = gd.getDefaultConfiguration(); Rectangle screenBounds = gc.getBounds(); if (screenBounds.contains(pos)) { lstDevices.add(gd); } } if (lstDevices.size() == 1) { device = lstDevices.get(0); } return device; } public static Rectangle getScreenBoundsAt(Point pos) { GraphicsDevice gd = getGraphicsDeviceAt(pos); Rectangle bounds = null; if (gd != null) { bounds = gd.getDefaultConfiguration().getBounds(); } return bounds; } </code></pre> <p>The basic idea is to provide a screen location and find the screen that matches it. I have variations the take a <code>Component</code> or <code>Window</code> but essentially, it boils down to this.</p> <p>From a <code>MouseEvent</code>, you can obtain the screen coordinates simply enough with a call to <a href="http://docs.oracle.com/javase/7/docs/api/java/awt/event/MouseEvent.html#getLocationOnScreen%28%29" rel="nofollow">MouseEvent.getLocationOnScreen</a></p> <p>Now, from your question, it sounds like you want to know the entire "virtual" screen bounds (I might be wrong), but I use this method (actually I use it to create multi-monitor wallpapers on the fly, but that's another question)</p> <pre><code>public static Rectangle getVirtualScreenBounds() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice lstGDs[] = ge.getScreenDevices(); Rectangle bounds = new Rectangle(); for (GraphicsDevice gd : lstGDs) { bounds.add(gd.getDefaultConfiguration().getBounds()); } return bounds; } </code></pre> <p>Basically, it just walks all the screen devices and add's there regions together to form a "virtual" rectangle. You could use the same concept to return the bounds of each screen device as an array instead.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload