Class WindowWidget


public class WindowWidget extends ScrollPanelWidget
Represents a Widget panel that can be customized with various properties such as font, title, header color, and header height.
  • Constructor Details

    • WindowWidget

      public WindowWidget(String title, int x, int y, int width, int height)
      Constructs a new Widget with the specified position and size.
      Parameters:
      title - window title
      x - the x-coordinate of the Widget's position
      y - the y-coordinate of the Widget's position
      width - the width of the Widget
      height - the height of the Widget
  • Method Details

    • closeWindow

      public final void closeWindow()
      Closing a window (removes it from the screen)
    • onInitialize

      public void onInitialize()
      Initializes the Widget
      Overrides:
      onInitialize in class ScrollPanelWidget
    • getMinSizeX

      public final int getMinSizeX()
      Returns the minimum width of the widget.
      Returns:
      the minimum width of the widget in pixels.
    • setMinSizeX

      public final void setMinSizeX(int minSizeX)
      Sets the minimum width of the widget.
      Parameters:
      minSizeX - the minimum width of the widget in pixels.
    • getMinSizeY

      public final int getMinSizeY()
      Returns the minimum height of the widget.
      Returns:
      the minimum height of the widget in pixels.
    • setMinSizeY

      public final void setMinSizeY(int minSizeY)
      Sets the minimum height of the widget.
      Parameters:
      minSizeY - the minimum height of the widget in pixels.
    • isResizable

      public final boolean isResizable()
      Checks if the widget is resizable.
      Returns:
      true if the widget is resizable, false otherwise.
    • setResizable

      public final void setResizable(boolean resizable)
      Sets the ability to resize the widget.
      Parameters:
      resizable - true if the widget is resizable, false otherwise.
    • addChild

      public void addChild(Widget widget)
      Adds a child widget to this widget's list of children.
      Overrides:
      addChild in class ScrollPanelWidget
      Parameters:
      widget - the widget to add as a child
    • removeChild

      public void removeChild(Widget widget)
      Removes a child widget from this widget's list of children.
      Overrides:
      removeChild in class ScrollPanelWidget
      Parameters:
      widget - the widget to remove from the list of children
    • setFont

      public final void setFont(String fontName)
      Sets the font name for the Widget.
      Parameters:
      fontName - the name of the font to use, specified as a string (e.g., "Arial", "Helvetica")
    • setTitle

      public final void setTitle(String title)
      Sets the title of the Widget's header.
      Parameters:
      title - the title text to display in the header
    • getFontName

      public final String getFontName()
      Gets the current font name used by the Widget.
      Returns:
      the name of the font being used
    • getTitle

      public final String getTitle()
      Gets the current title of the Widget's header.
      Returns:
      the title text currently set for the header
    • setHeaderColor

      public final void setHeaderColor(NanoColor headerColor)
      Sets the color of the Widget's header.
      Parameters:
      headerColor - the color to use for the header
    • setHeaderHeight

      public final void setHeaderHeight(int headerHeight)
      Sets the height of the Widget's header.
      Parameters:
      headerHeight - the height of the header in pixels
    • getHeaderHeight

      public final int getHeaderHeight()
      Returns the height of the Widget's header
      Returns:
      header height in pixels
    • onLeftMouseDown

      public void onLeftMouseDown(int x, int y)
      Called when the left mouse button is pressed down over the Widget.
      Overrides:
      onLeftMouseDown in class PanelWidget
      Parameters:
      x - relative x-coordinate of the mouse position
      y - relative y-coordinate of the mouse position
    • onLeftMouseUpOutside

      public void onLeftMouseUpOutside(int x, int y)
      Handles the left mouse button up event outside any visible Widget
      Overrides:
      onLeftMouseUpOutside in class PanelWidget
      Parameters:
      x - absolute x-coordinate of the mouse position
      y - absolute y-coordinate of the mouse position
    • onLeftMouseUp

      public void onLeftMouseUp(int x, int y)
      Called when the left mouse button is released over the Widget.
      Overrides:
      onLeftMouseUp in class PanelWidget
      Parameters:
      x - relative x-coordinate of the mouse position
      y - relative y-coordinate of the mouse position
    • update

      public void update()
      Updates the Widget
      Overrides:
      update in class ScrollPanelWidget
    • renderChildren

      public void renderChildren()
      Updates and renders all child widgets of this Widget. This method recursively calls the update and render methods on each child widget, ensuring that the rendering order respects the hierarchy of widgets.
      Overrides:
      renderChildren in class ScrollPanelWidget
    • render

      public void render()
      Renders the Widget
      Overrides:
      render in class PanelWidget
    • postRender

      public void postRender()
      Final rendering, after the main render and rendering of child elements
      Overrides:
      postRender in class PanelWidget