Get the screen bounds of each screen - Java 2D Graphics

Java examples for 2D Graphics:Screen

Description

Get the screen bounds of each screen

Demo Code


//package com.java2s;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;

public class Main {
    /**/*from  w  w  w .  ja  v  a  2  s.c  o  m*/
     * Get the screen bounds of each screen
     *
     * @return The screen size
     */
    public static Rectangle[] getAllScreenBounds() {
        GraphicsEnvironment ge = GraphicsEnvironment
                .getLocalGraphicsEnvironment();
        GraphicsDevice[] screens = ge.getScreenDevices();

        Rectangle[] allScreenBounds = new Rectangle[screens.length];
        for (int i = 0; i < screens.length; i++) {
            allScreenBounds[i] = screens[i].getDefaultConfiguration()
                    .getBounds();
        }
        return allScreenBounds;
    }
}

Related Tutorials