Here you can find the source of centreJustifyFrame(final JFrame frame, final int y_position)
public static void centreJustifyFrame(final JFrame frame, final int y_position)
//package com.java2s; /* Utilities.java//from w ww. j a va 2 s . c o m * * created: Tue Sep 18 2001 * * This file is part of Artemis * * Copyright(C) 2001 Genome Research Limited * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or(at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/Utilities.java,v 1.4 2007-02-22 19:45:18 tjc Exp $ */ import java.awt.*; import javax.swing.*; public class Main { /** * Move the given JFrame to the centre of the screen. **/ public static void centreJustifyFrame(final JFrame frame, final int y_position) { final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); final int x_position = (screen.width - frame.getSize().width) / 2; frame.setLocation(new Point(x_position, y_position)); } }