Java JFrame centreJustifyFrame(final JFrame frame, final int y_position)

Here you can find the source of centreJustifyFrame(final JFrame frame, final int y_position)

Description

Move the given JFrame to the centre of the screen.

License

Open Source License

Declaration

public static void centreJustifyFrame(final JFrame frame, final int y_position) 

Method Source Code


//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));
    }
}

Related

  1. buildTxtField(JFrame frame, int x, int y, int w, int h)
  2. calcLocation(JFrame main, JDialog dialog)
  3. calculateMaxMenuItems(JFrame window)
  4. calculateMaxMenuItems(JFrame window)
  5. centre(JFrame frame)
  6. centreWindow(Window c, JFrame frame)
  7. changeLookAndFeel(final String lookName, final JFrame frame)
  8. chooseFile(String directoryPath, String dialogTitle, String selectedFileName, boolean saveDialog, String[] extensions, JFrame parentFrame)
  9. ChooserDemo(JFrame jf, Component comp)