Java Screen Full Size locateOnOpticalScreenCenter(Component component)

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

Description

Locates the given component on the screen's center.

License

Open Source License

Parameter

Parameter Description
component the component to be centered

Declaration

public static void locateOnOpticalScreenCenter(Component component) 

Method Source Code


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

public class Main {
    /**// w ww  .  j  av  a  2  s.  c  om
     * Locates the given component on the screen's center.
     * 
     * @param component   the component to be centered
     */
    public static void locateOnOpticalScreenCenter(Component component) {
        Dimension paneSize = component.getSize();
        Dimension screenSize = component.getToolkit().getScreenSize();
        component.setLocation((screenSize.width - paneSize.width) / 2,
                (int) ((screenSize.height - paneSize.height) * 0.45));
    }
}

Related

  1. fullScreen(Component component)
  2. fullScreen(Window window)
  3. getOppositeFullScreenBoundsFor(Rectangle r, boolean includeReservedInsets)
  4. initializeScreenArea(int priority)
  5. locateInScreenCenter(Component c)
  6. setFrameToMiddleOfTheScreen(Window window)
  7. setWindowCanFullScreen(Window w, boolean flag)
  8. showOnSameScreenAsMouseCenter(Container frame)