Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.awt.Dimension;

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

public class Main {
    public static void center(Window window) {
        final Dimension size = window.getSize();
        final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
        final int locX = (screen.width - size.width) / 2;
        final int locY = (screen.height - size.height) / 2;
        window.setLocation(locX, locY);
    }
}