java.lang.Object
io.github.astrapi69.awt.screen.ScreenSizeExtensions

public final class ScreenSizeExtensions extends Object
Utility class for handle with screensize.
  • Method Details

    • maximize

      public static void maximize(@NonNull @NonNull Component component)
      Maximizes the given Window from the given component
      Parameters:
      component - the component
    • maximize

      public static void maximize(@NonNull @NonNull Window window)
      Maximizes the given Window
      Parameters:
      window - the window
    • centralize

      public static void centralize(@NonNull @NonNull Component component, int divideScreenWith, int divideScreenHeight)
      Set given Window to the center of the device and divide them with the given arguments
      Parameters:
      component - the component
      divideScreenWith - the value to divide with the screen with
      divideScreenHeight - the value to divide with the screen height
    • centralize

      public static void centralize(@NonNull @NonNull Window window, int divideScreenWith, int divideScreenHeight)
      Set given Window to the center of the device and divide them with the given arguments
      Parameters:
      window - the window
      divideScreenWith - the value to divide with the screen with
      divideScreenHeight - the value to divide with the screen height
    • computeDialogPositions

      public static List<Point> computeDialogPositions(int dialogWidth, int dialogHeight)
      Compute how much dialog can be put into the screen and returns a list with the coordinates from the dialog positions as Point objects.
      Parameters:
      dialogWidth - the dialog width
      dialogHeight - the dialog height
      Returns:
      the list with the computed Point objects.
    • getFirstScreenHeight

      public static int getFirstScreenHeight()
      Gets the first screen width.
      Returns:
      the first screen width.
    • getFirstScreenWidth

      public static int getFirstScreenWidth()
      Gets the first screen width.
      Returns:
      the first screen width.
    • getGraphicsConfiguration

      public static GraphicsConfiguration getGraphicsConfiguration(int screenID)
      Gets the GraphicsConfiguration from the given screen id
      Parameters:
      screenID - the screen id
      Returns:
      the GraphicsConfiguration object from the given screen id
    • getPoint

      public static Point getPoint()
      Gets the Screensize and returns it as a Point object.
      Returns:
      A Point object.
    • getScreenDevice

      public static GraphicsDevice getScreenDevice(int screenID)
      Gets the screen device from the given screen id
      Parameters:
      screenID - the screen id
      Returns:
      the GraphicsDevice object from the given screen id
    • getScreenDevices

      public static GraphicsDevice[] getScreenDevices()
      Gets all the screen devices.
      Returns:
      the screen devices
    • getScreenDimension

      public static Dimension getScreenDimension(Component component)
      Gets the screen dimension.
      Parameters:
      component - the component
      Returns:
      the screen dimension
    • getScreenHeight

      public static int getScreenHeight()
      Gets the height from the current screen.
      Returns:
      Returns the height from the current screen.
    • getScreenSizeDimension

      public static Dimension getScreenSizeDimension()
      Gets the Dimension object from the current screen size
      Returns:
      Returns the Dimension object from the current screen size
    • getScreenHeight

      public static int getScreenHeight(Component component)
      Gets the screen height of the GraphicsDevice that is displayed from the given component
      Parameters:
      component - the component
      Returns:
      the screen height
    • getScreenHeight

      public static double getScreenHeight(GraphicsConfiguration graphicsConfiguration)
      Gets the screen width from the given GraphicsConfiguration object
      Parameters:
      graphicsConfiguration - the graphic configuration object
      Returns:
      the screen width.
    • getScreenHeight

      public static int getScreenHeight(GraphicsDevice graphicsDevice)
      Gets the screen height from the given GraphicsDevice object.
      Parameters:
      graphicsDevice - the GraphicsDevice object.
      Returns:
      the screen height from the given GraphicsDevice object.
    • getScreenID

      public static int getScreenID(Component component)
      Gets the screen ID from the given component
      Parameters:
      component - the component
      Returns:
      the screen ID
    • getScreenWidth

      public static int getScreenWidth()
      Gets the width from the current screen.
      Returns:
      Returns the width from the current screen.
    • getScreenWidth

      public static int getScreenWidth(Component component)
      Gets the screen width of the GraphicsDevice that is displayed from the given component
      Parameters:
      component - the component
      Returns:
      the screen width
    • getScreenWidth

      public static double getScreenWidth(GraphicsConfiguration graphicsConfiguration)
      Gets the screen width from the given GraphicsConfiguration object
      Parameters:
      graphicsConfiguration - the graphic configuration object
      Returns:
      the screen width.
    • getScreenWidth

      public static int getScreenWidth(GraphicsDevice graphicsDevice)
      Gets the screen width from the given GraphicsDevice object.
      Parameters:
      graphicsDevice - the GraphicsDevice object.
      Returns:
      the screen width from the given GraphicsDevice object.
    • showFrame

      public static void showFrame(@NonNull @NonNull Frame frame)
      Bring the given Frame to the front
      Parameters:
      frame - the frame
    • setDefaultFrameSize

      public static void setDefaultFrameSize(@NonNull @NonNull Frame frame)
      Sets the default sceen size from the given Frame
      Parameters:
      frame - the frame
    • toggleFullScreen

      public static void toggleFullScreen(@NonNull @NonNull JFrame frame)
      Toggle given Frame to full screen mode or if it is in full screen mode its returns to normal mode
      Parameters:
      frame - the frame
    • setComponentPosition

      public static void setComponentPosition(Component component, ComponentPositionModel componentPositionModel)
      Positions the given window from the given position model
      Parameters:
      component - the window
      componentPositionModel - the window position model