Example usage for java.awt Container setLocation

List of usage examples for java.awt Container setLocation

Introduction

In this page you can find the example usage for java.awt Container setLocation.

Prototype

public void setLocation(Point p) 

Source Link

Document

Moves this component to a new location.

Usage

From source file:Main.java

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);
}