Java JFrame Center centerWindow(JFrame frame)

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

Description

center Window

License

Open Source License

Declaration

public static void centerWindow(JFrame frame) 

Method Source Code


//package com.java2s;
import javax.swing.*;
import java.awt.*;

public class Main {
    public static void centerWindow(JFrame frame) {
        Toolkit tk = Toolkit.getDefaultToolkit();
        Dimension screenSize = tk.getScreenSize();
        int screenHeight = screenSize.height;
        int screenWidth = screenSize.width;
        frame.setLocation(screenWidth / 4, screenHeight / 4);
    }//  w w  w  .j av  a  2s.  com
}

Related

  1. centerOnScreen(JFrame frame, int screenID)
  2. centerPoint(int width, int height, JFrame frame)
  3. centerPosition(JFrame invokerFrame, Window w, int width, int height)
  4. centerWindow(JFrame frame)
  5. centerWindow(JFrame frame)
  6. centerWindow(JFrame window)
  7. centerWindowInFrame(Component window, Window frame)
  8. centerWindowOnParent(Window w, JFrame parent)
  9. centerWithinDesktop(JInternalFrame frame)