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 {
    /**
     * Centraliza a janela na tela
     * @param w janela a ser centralizada
     */
    public static void center(Window w) {
        Dimension us = w.getSize(), them = Toolkit.getDefaultToolkit().getScreenSize();
        int newX = (them.width - us.width) / 2;
        int newY = (them.height - us.height) / 2;
        w.setLocation(newX, newY);
    }
}