Java Screen Center centreOnScreen(Window frame)

Here you can find the source of centreOnScreen(Window frame)

Description

Centres a window to screen

License

Open Source License

Parameter

Parameter Description
frame a parameter

Declaration

public static void centreOnScreen(Window frame) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.Window;

public class Main {
    /**//from   ww w .  j av a2 s  . co m
     * Centres a window to screen
     *
     * @param frame
     */
    public static void centreOnScreen(Window frame) {
        //        Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
        //        int x = (int) ((dimension.getWidth() - frame.getWidth()) / 2.0D);
        //        int y = (int) ((dimension.getHeight() - frame.getHeight()) / 2.0D);
        //        frame.setLocation(x, y);
        frame.setLocationRelativeTo(null);
    }
}

Related

  1. centreOnScreen(Window win)
  2. getCenter(Component owner, Dimension size)
  3. getCenterCoordinates(Dimension d)
  4. getCenteredLocation(Component comp)