Java examples for java.awt:Window
position Component In Center Screen
/*/*from ww w. j av a2 s. c om*/ * @(#) DialogUtilities.java 1.0 3/5/2004 * * Copyright (c) 2004 University of York * All rights reserved * */ //package com.java2s; import java.awt.*; public class Main { public static void positionInCenterScreen(Component c, int height, int width) { Rectangle screen = GraphicsEnvironment .getLocalGraphicsEnvironment().getMaximumWindowBounds(); int left, top; left = (int) (screen.getWidth() - width) / 2; top = (int) (screen.getHeight() - height) / 2; c.setBounds(left, top, width, height); } }