Get screen area of all monitors. - Java Swing

Java examples for Swing:Screen

Description

Get screen area of all monitors.

Demo Code

/*/*from w  w w .  j  a  v  a 2  s  .  c  o  m*/
 * @(#)PortingUtils.java 4/12/2006
 *
 * Copyright 2002 - 2006 JIDE Software Inc. All rights reserved.
 */
//package com.java2s;

import java.awt.*;

import java.awt.geom.Area;

public class Main {
    /**
     * Get screen area of all monitors.
     *
     * @return Union of all screens
     */
    public static Area getScreenArea() {
        Area SCREEN_AREA = new Area();
        GraphicsEnvironment environment = GraphicsEnvironment
                .getLocalGraphicsEnvironment();
        GraphicsDevice[] screenDevices = environment.getScreenDevices();
        for (GraphicsDevice device : screenDevices) {
            GraphicsConfiguration configuration = device
                    .getDefaultConfiguration();
            Rectangle screenBounds = configuration.getBounds();
            SCREEN_AREA.add(new Area(screenBounds));
        }
        return SCREEN_AREA;
    }
}

Related Tutorials