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 center of the first display.
     * @return  the center (displayWidht/2,diplayHight/2) of the first display.
     */
    public static Point getScreenCenter() {
        Dimension dimension = getScreenSize();
        return new Point(dimension.width / 2, dimension.height / 2);
    }

    /** Returns the Screen resolution. If there're more than one display you might want to use: {@link #getScreenSizes()} 
     * @return the Screen resolution
     * @see #getScreenSizes()
     */
    public static Dimension getScreenSize() {
        return Toolkit.getDefaultToolkit().getScreenSize();
    }
}