Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.Window;

public class Main {
    public static void centerOnScreen(final Window window) {
        final Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();
        final Dimension windowSize = window.getSize();

        final int x = (screensize.width - windowSize.width) / 2;
        final int y = (screensize.height - windowSize.height) / 2;

        window.setLocation(x, y);
    }
}