Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Toolkit;

public class Main {
    public static void setScreenCenter(Container container) {
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Dimension screenDimension = toolkit.getScreenSize();
        int width = container.getWidth();
        int height = container.getHeight();
        Point point = new Point();
        point.setLocation((screenDimension.getWidth() - width) / 2, (screenDimension.getHeight() - height) / 2);
        container.setLocation(point);
    }
}