center Frame Window - Java Swing

Java examples for Swing:JFrame

Description

center Frame Window

Demo Code


//package com.java2s;
import java.awt.Dimension;

import java.awt.Toolkit;
import java.awt.Window;

public class Main {
    public static void centerFrame(Window window) {
        Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
        window.setLocation((dim.width - window.getSize().width) / 2,
                (dim.height - window.getSize().height) / 2);
    }/*from w ww  .  j  a  va 2  s. co  m*/
}

Related Tutorials