Class PositionUtil


  • public final class PositionUtil
    extends Object
    Class which provides methods to set the dimension and position of windows in the middle of the screen or in the middle of another window
    • Method Detail

      • setPositionMiddleScreen

        public static void setPositionMiddleScreen​(Window window,
                                                   Component parent)
        Sets the position of the window to the middle of the screen. This method will try to place the window on the same screen as the parent if provided, otherwise the main screen is used.
        Parameters:
        window - Window
        parent - Parent Window
      • getScreenDeviceOfComponent

        public static GraphicsDevice getScreenDeviceOfComponent​(Component comp)
        Returns the screen device of the given component or null if not found
        Parameters:
        comp - Component
        Returns:
        Screen device of the given component or null if not found
      • getCenterPoint

        public static Point getCenterPoint​(Rectangle bounds)
        Center point of bounds
        Parameters:
        bounds - Bounds
        Returns:
        Center point of bounds
      • getCenterPoint

        public static Point getCenterPoint​(int x,
                                           int y,
                                           int width,
                                           int height)
        Center point of bounds
        Parameters:
        x - X
        y - Y
        width - Width
        height - Height
        Returns:
        Center point of bounds