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 {
    /**
     * centers the frame in the center of the screen
     *
     * @param pFrame Frame to center
     */
    static public void centerWindow(Window pFrame) {
        Point center = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint();
        center.x = center.x - (int) pFrame.getSize().getWidth() / 2;
        center.y = center.y - (int) pFrame.getSize().getHeight() / 2;
        pFrame.setLocation(center);
    }
}