Class PositionUtil
- java.lang.Object
-
- ch.supertomcat.supertomcatutils.gui.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 Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static PointgetCenterPoint(int x, int y, int width, int height)Center point of boundsstatic PointgetCenterPoint(Rectangle bounds)Center point of boundsstatic GraphicsDevicegetScreenDeviceOfComponent(Component comp)Returns the screen device of the given component or null if not foundstatic voidsetPositionMiddleScreen(Window window, Component parent)Sets the position of the window to the middle of the screen.
-
-
-
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- Windowparent- 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- Xy- Ywidth- Widthheight- Height- Returns:
- Center point of bounds
-
-