Here you can find the source of setLocationCentral(final Component component)
Parameter | Description |
---|---|
component | a parameter |
public static void setLocationCentral(final Component component)
//package com.java2s; /******************************************************************************* * Manchester Centre for Integrative Systems Biology * University of Manchester/*from w w w.j a v a 2 s .c o m*/ * Manchester M1 7ND * United Kingdom * * Copyright (C) 2007 University of Manchester * * This program is released under the Academic Free License ("AFL") v3.0. * (http://www.opensource.org/licenses/academic.php) *******************************************************************************/ import java.awt.*; public class Main { /** * * @param component */ public static void setLocationCentral(final Component component) { final Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize(); final Dimension frameDimension = component.getSize(); final int x = (screenDimension.width - frameDimension.width) / 2; final int y = (screenDimension.height - frameDimension.height) / 2; component.setLocation(x, y); } }