Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    /**
     * Centralizar componente
     * @author marcos
     * @param janela
     */
    public static void centralizar(java.awt.Component janela) {
        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        java.awt.Rectangle b = janela.getBounds();
        int x, y;//height, width;

        x = (screenSize.width - b.width) / 2;
        y = (screenSize.height - b.height) / 2;
        janela.setLocation(x, y);
    }
}