Class TextBoxObject

java.lang.Object
com.iragui.objects.GUIObject
com.iragui.objects.TextBoxObject
Direct Known Subclasses:
WritableTextBoxObject

public class TextBoxObject extends GUIObject
A TextBoxObject represents a multi-line text container within the GUI.

Each line of text is internally represented as a TextObject and stored in a TreeMap. The text box manages positioning, spacing between lines, and propagates updates (such as position, limits, and layer changes) to its child TextObjects.

  • Field Details

  • Constructor Details

    • TextBoxObject

      public TextBoxObject(String name, int layer, GUI gui, int x, int y, int sizeX, int sizeY, boolean nearestFilter, boolean rgba, int lineSpacing)
      Constructs a new TextBoxObject.
      Parameters:
      name - the unique object name
      layer - the rendering layer
      gui - the parent GUI
      x - the x-position
      y - the y-position
      sizeX - the width of the text box
      sizeY - the height of the text box
      nearestFilter - whether to use nearest-neighbor filtering
      rgba - whether to use RGBA textures
      lineSpacing - vertical spacing between lines
  • Method Details

    • appendLine

      public void appendLine(String text, Font font, Color color, Color bkgColor, boolean rgba, boolean nearestFilter, boolean antiAliasing)
      Appends a new line of text to this text box.
      Parameters:
      text - the string content
      font - the font used to render the text
      color - the text color
      bkgColor - the background color
      rgba - whether the text uses RGBA
      nearestFilter - whether to use nearest-neighbor filtering
      antiAliasing - whether to apply anti-aliasing
    • getLineSpacing

      public int getLineSpacing()
      Returns:
      the vertical spacing between lines.
    • setLineSpacing

      public void setLineSpacing(int space)
      Sets the vertical spacing between lines.
      Parameters:
      space - the line spacing in pixels
    • setLayer

      public void setLayer(int layer)
      Sets the rendering layer and updates parent GUI ordering.
      Overrides:
      setLayer in class GUIObject
    • destroyObject

      public void destroyObject()
      Destroys this object, releasing GPU resources and unregistering it.

      If preserveTextureIDOverride is true, the OpenGL texture ID will not be deleted. See GUIObject.setPreserveTextureIDOverride(boolean).

      Overrides:
      destroyObject in class GUIObject
    • setX

      public void setX(int x)
      Sets the X position in pixels.
      Overrides:
      setX in class GUIObject
    • setY

      public void setY(int y)
      Sets the Y position in pixels.
      Overrides:
      setY in class GUIObject
    • setLimitX

      public void setLimitX(int x)
      Overrides:
      setLimitX in class GUIObject
    • setMinX

      public void setMinX(int x)
      Overrides:
      setMinX in class GUIObject
    • setMinY

      public void setMinY(int y)
      Overrides:
      setMinY in class GUIObject
    • setLimitY

      public void setLimitY(int y)
      Overrides:
      setLimitY in class GUIObject
    • setWinLimitX

      public void setWinLimitX(int x)
      Overrides:
      setWinLimitX in class GUIObject
    • setWinLimitY

      public void setWinLimitY(int y)
      Overrides:
      setWinLimitY in class GUIObject
    • setWinMinX

      public void setWinMinX(int x)
      Overrides:
      setWinMinX in class GUIObject
    • setWinMinY

      public void setWinMinY(int y)
      Overrides:
      setWinMinY in class GUIObject
    • update

      public void update(boolean showFrame)
      Description copied from class: GUIObject
      Update logic called each frame.
      Specified by:
      update in class GUIObject
    • sendKey

      public void sendKey(int key, int action)
      Description copied from class: GUIObject
      Handles key input events.
      Specified by:
      sendKey in class GUIObject
    • sendMousePos

      public void sendMousePos(long window, double xPos, double yPos)
      Description copied from class: GUIObject
      Handles mouse position updates.
      Specified by:
      sendMousePos in class GUIObject
    • sendMouseButton

      public void sendMouseButton(long window, int button, int action, int mods)
      Description copied from class: GUIObject
      Handles mouse button input.
      Specified by:
      sendMouseButton in class GUIObject
    • sendMouseScroll

      public void sendMouseScroll(long window, double xOffset, double yOffset)
      Description copied from class: GUIObject
      Handles mouse scroll input.
      Specified by:
      sendMouseScroll in class GUIObject
    • getLines

      public TreeMap<Integer, TextObject> getLines()
      Returns:
      all text lines as a TreeMap.