Class GameWindow

java.lang.Object
de.gurkenlabs.litiengine.GameWindow

public final class GameWindow
extends java.lang.Object
The GameWindow class is a wrapper for the game's visual window in which the RenderComponent lives.
It provides the possibility to set a title, provide an icon, configure the cursor or get information about the resolution.
See Also:
RenderComponent, getResolution(), setTitle(String), cursor(), setIcon(java.awt.Image)
  • Nested Class Summary

    Nested Classes 
    Modifier and TypeClassDescription
    static interface GameWindow.ResolutionChangedListener
    This listener interface receives resolution changed events of the game window.
  • Method Summary

    Modifier and TypeMethodDescription
    MouseCursorcursor()
    Gets the visual representation of the mouse cursor on the GameWindow.
    java.awt.geom.Point2DgetCenter()
    Gets the current resolution scale.
    intgetHeight()
    Gets the window height.
    java.awt.ContainergetHostControl()
    Gets the GameWindow's JFrame, abstracted as a Container.
    java.awt.PointgetLocationOnScreen()
    Gets the screen location of the window's top left corner.
    RenderComponentgetRenderComponent()
    Gets the AWT canvas that is used to render the game's content on.
    java.awt.DimensiongetResolution()
    Gets the window resolution wrapped in a Dimension object.
    floatgetResolutionScale()
    Gets the current resolution scale.
    java.awt.DimensiongetSize()
    Gets the window width and height wrapped in a Dimension object.
    intgetWidth()
    Gets the window width.
    booleanisFocusOwner()
    Returns true if the GameWindow is the focus owner.
    voidonResolutionChanged​(GameWindow.ResolutionChangedListener listener)
    Adds the specified resolution changed listener to receive events when the dimensions of this game window are changed.
    voidremoveResolutionChangedListener​(GameWindow.ResolutionChangedListener listener)
    Removes the specified resolution changed listener.
    voidsetIcon​(java.awt.Image image)
    Sets the icon image for the window's hosting JFrame.
    voidsetIcons​(java.util.List<? extends java.awt.Image> images)
    Sets the icons for the window's hosting JFrame.
    voidsetResolution​(Resolution res)
    Sets the resolution for the GameWindow.
    voidsetTitle​(java.lang.String title)
    Sets the title for this window to the specified string.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • isFocusOwner

      public boolean isFocusOwner()
      Returns true if the GameWindow is the focus owner.
      Returns:
      true if the GameWindow is the focus owner; false otherwise
    • onResolutionChanged

      public void onResolutionChanged​(GameWindow.ResolutionChangedListener listener)
      Adds the specified resolution changed listener to receive events when the dimensions of this game window are changed.
      Parameters:
      listener - The listener to add.
    • removeResolutionChangedListener

      public void removeResolutionChangedListener​(GameWindow.ResolutionChangedListener listener)
      Removes the specified resolution changed listener.
      Parameters:
      listener - The listener to remove.
    • setResolution

      public void setResolution​(Resolution res)
      Sets the resolution for the GameWindow.
      Parameters:
      res - The desired Resolution to set for the GameWindow.
      See Also:
      Resolution
    • getResolutionScale

      public float getResolutionScale()
      Gets the current resolution scale. The resolution scale is a float value dictating how much larger or smaller each pixel is rendered on screen.
      Returns:
      The GameWindow's current resolution scale.
    • getCenter

      public java.awt.geom.Point2D getCenter()
      Gets the current resolution scale. The resolution scale is a float value dictating how much larger or smaller each pixel is rendered on screen.
      Returns:
      The GameWindow's current resolution scale.
    • getHostControl

      public java.awt.Container getHostControl()
      Gets the GameWindow's JFrame, abstracted as a Container.
      Returns:
      The GameWindow's JFrame as an abstract AWT Container.
    • getSize

      public java.awt.Dimension getSize()
      Gets the window width and height wrapped in a Dimension object.
      Returns:
      The GameWindow's size as a Dimension.
    • getWidth

      public int getWidth()
      Gets the window width.
      Returns:
      The window width.
    • getHeight

      public int getHeight()
      Gets the window height.
      Returns:
      The window height.
    • getRenderComponent

      public RenderComponent getRenderComponent()
      Gets the AWT canvas that is used to render the game's content on.
      Returns:
      The AWT render component onto which the game contents are rendered.
    • cursor

      public MouseCursor cursor()
      Gets the visual representation of the mouse cursor on the GameWindow.

      This can be used to provide a custom cursor image, define its visibility or specify a rendering offset from the actual position.

      Returns:
      The mouse cursor of the game.
    • getResolution

      public java.awt.Dimension getResolution()
      Gets the window resolution wrapped in a Dimension object.
      Returns:
      The GameWindow's internal resolution as a Dimension.
    • getLocationOnScreen

      public java.awt.Point getLocationOnScreen()
      Gets the screen location of the window's top left corner.
      Returns:
      The Point of the window's top left corner.
      See Also:
      Component.getLocationOnScreen()
    • setIcon

      public void setIcon​(java.awt.Image image)
      Sets the icon image for the window's hosting JFrame.
      Parameters:
      image - The Image to be used as the window icon.
      See Also:
      JFrame.setIconImage(java.awt.Image)
    • setIcons

      public void setIcons​(java.util.List<? extends java.awt.Image> images)
      Sets the icons for the window's hosting JFrame. Depending on the platform specifications, one or several Icons with the correct Dimension will be chosen automatically from the list.
      Parameters:
      images - A list of Images to be used as the window icons.
      See Also:
      Window.setIconImages(java.util.List<? extends java.awt.Image>)
    • setTitle

      public void setTitle​(java.lang.String title)
      Sets the title for this window to the specified string.
      Parameters:
      title - the window title to be displayed in the frame's border. A null value is treated as an empty string, "".
      See Also:
      Frame.setTitle(java.lang.String)