Example usage for java.awt Dialog setLocation

List of usage examples for java.awt Dialog setLocation

Introduction

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

Prototype

@Override
public void setLocation(int x, int y) 

Source Link

Document

The method changes the geometry-related data.

Usage

From source file:Main.java

/** Repositions a frame to be centered on the screen */
public static void center(Dialog frame) {
    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension screen = tk.getScreenSize();
    Dimension win = frame.getSize();
    //frame.setSize(screenWidth / 2, screenHeight / 2);
    frame.setLocation((screen.width - win.width) / 2, (screen.height - win.height) / 2);
}