Java Screen Center setCenterLocation(final Window window)

Here you can find the source of setCenterLocation(final Window window)

Description

set Center Location

License

Open Source License

Declaration

public synchronized static void setCenterLocation(final Window window) 

Method Source Code


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

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

Related

  1. setCenter(Component component)
  2. setCenter(Component component, Component component1)
  3. setCenteredCoordSystem(Graphics2D g, Component comp, double unitx, double unity)
  4. setCenteredInScreen(Component frame)
  5. setCenteredRectangle(int rectangleWidth, int rectangleHeight)
  6. setCenterPosition(final Frame frame)
  7. setComponentLocationOnCenter(Component component)
  8. setLocationCentral(final Component component)
  9. setLocationOnScreenToCenteredWithin(java.awt.Window window, java.awt.Component root)