Java Screen Size getDesktopBounds()

Here you can find the source of getDesktopBounds()

Description

get the bounds of the users desktop...

License

Open Source License

Declaration

public static Rectangle getDesktopBounds() 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.awt.*;

public class Main {
    /**/*ww  w  . java 2 s .  com*/
     * get the bounds of the users desktop... including if it uses multiple monitors.
     * See the Documentation on Class GraphicsConfiguration.
     */
    public static Rectangle getDesktopBounds() {
        Rectangle virtualBounds = new Rectangle();
        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice[] gs = ge.getScreenDevices();
        for (int j = 0; j < gs.length; j++) {
            GraphicsDevice gd = gs[j];
            GraphicsConfiguration gc = gd.getDefaultConfiguration();
            Rectangle rect = gc.getBounds();
            if (rect != null)
                virtualBounds = virtualBounds.union(rect);

            //            GraphicsConfiguration[] gc =gd.getConfigurations();
            //            for (int i=0; i  < gc.length; i++) {
            //                 Rectangle rect = gc[i].getBounds();
            //                 if( rect != null )
            //                     virtualBounds = virtualBounds.union(rect);
            //            }
        }
        return virtualBounds;
    }
}

Related

  1. getDefaultScreenBounds()
  2. getDefaultScreenDevice()
  3. getDefaultScreenSize()
  4. getDefaultScreenSizeWithoutAdjustment()
  5. getDesktopBounds()
  6. getLocalScreenBounds()
  7. getLocationFromMouse(Dimension panelPrefSize_)
  8. getMaximumWindowBounds()
  9. getMaximumWindowBounds()