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.Component;
import java.awt.Dimension;

import java.awt.Toolkit;

public class Main {
    /**
     * Centers the component on the screen
     */
    public static void centerOnScreen(Component comp) {
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        comp.setLocation((screenSize.width - comp.getWidth()) / 2, (screenSize.height - comp.getHeight()) / 2);
    }
}