Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.awt.*;

public class Main {
    /** Returns the Screen resolution of all available displays. If ther's only one display you might use: {@link #getScreenSize()}
     * @return Screen resolution of all available displays.
     * @see #getScreenSize()
     */
    public static Dimension[] getScreenSizes() {
        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice[] gs = ge.getScreenDevices(); // Get size of each screen
        Dimension[] dimension = new Dimension[gs.length];
        for (int i = 0; i < gs.length; i++) {
            DisplayMode dm = gs[i].getDisplayMode();
            dimension[i] = new Dimension(dm.getWidth(), dm.getHeight());
        }
        return dimension;
    }
}