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.Window;

public class Main {
    public static void centerWindowOnScreen(Window window) {
        int screenHeight = (int) window.getToolkit().getScreenSize().getHeight();
        int screenWidth = (int) window.getToolkit().getScreenSize().getWidth();
        int x = (screenWidth - window.getWidth()) / 2;
        int y = (screenHeight - window.getHeight()) / 2;
        window.setLocation(x, y);
    }
}