Java JFrame centre(JFrame frame)

Here you can find the source of centre(JFrame frame)

Description

centre

License

Open Source License

Declaration

public static void centre(JFrame frame) 

Method Source Code


//package com.java2s;

import java.awt.Dimension;

import java.awt.Toolkit;

import javax.swing.JFrame;

public class Main {
    public static void centre(JFrame frame) {
        //Center frame
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension size = frame.getSize();
        screenSize.height = screenSize.height / 2;
        screenSize.width = screenSize.width / 2;
        size.height = size.height / 2;/*w  ww  .j a v  a  2 s. c om*/
        size.width = size.width / 2;
        int y = screenSize.height - size.height;
        int x = screenSize.width - size.width;
        frame.setLocation(x, y);
    }
}

Related

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