get Screens - Java Swing

Java examples for Swing:Screen

Description

get Screens

Demo Code

/*//from w  w  w .  ja v  a2s .c  om
 * @(#)PortingUtils.java 4/12/2006
 *
 * Copyright 2002 - 2006 JIDE Software Inc. All rights reserved.
 */
//package com.java2s;

import java.awt.*;

import java.util.ArrayList;
import java.util.List;

public class Main {
    private static Rectangle[] getScreens() {
        GraphicsEnvironment environment = GraphicsEnvironment
                .getLocalGraphicsEnvironment();
        List<Rectangle> screensList = new ArrayList<Rectangle>();
        GraphicsDevice[] screenDevices = environment.getScreenDevices();
        for (GraphicsDevice device : screenDevices) {
            GraphicsConfiguration configuration = device
                    .getDefaultConfiguration();
            Rectangle screenBounds = configuration.getBounds();
            screensList.add(screenBounds);
        }
        return screensList.toArray(new Rectangle[screensList.size()]);
    }
}

Related Tutorials