Java Screen Center setCenter(Component component)

Here you can find the source of setCenter(Component component)

Description

set Center

License

Open Source License

Declaration

public static void setCenter(Component component) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.awt.*;

public class Main {
    public static void setCenter(Component component) {
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Dimension screenSize = toolkit.getScreenSize();
        component.setLocation(screenSize.width / 2 - component.getWidth() / 2,
                screenSize.height / 2 - component.getHeight() / 2);
    }/*w ww. j  a  va 2  s  .  c  o m*/
}

Related

  1. packAndCenter(Window wind)
  2. packAndCenter(Window window)
  3. screenCenter(Window window)
  4. setCenter(Component comp)
  5. setCenter(Component comp, Component parent)
  6. setCenter(Component component, Component component1)
  7. setCenteredCoordSystem(Graphics2D g, Component comp, double unitx, double unity)
  8. setCenteredInScreen(Component frame)
  9. setCenteredRectangle(int rectangleWidth, int rectangleHeight)