Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

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

import javax.swing.JFrame;

public class Main {
    /**
     * Position in center a JFrame
     *
     * @param jFrame
     */
    public static void center(JFrame jFrame) {
        Toolkit tk = Toolkit.getDefaultToolkit();
        Dimension screenSize = tk.getScreenSize();
        jFrame.setLocation((screenSize.width - jFrame.getSize().width) / 2,
                (screenSize.height - jFrame.getSize().height) / 2);
    }
}