Class FocusedTextWidget

All Implemented Interfaces:
Serializable, LayoutElement, Positionable

public final class FocusedTextWidget extends AbstractTextWidget

Represents a focusable text widget that displays a text message.

AbstractWidget.getWidth() serves as the text's maximum width. AbstractWidget.getHeight() is ignored.

See Also:
  • Field Details

    • DEFAULT_PADDING

      public static final int DEFAULT_PADDING
      The default padding around text elements.
      See Also:
  • Constructor Details

    • FocusedTextWidget

      public FocusedTextWidget(@NotNull @NotNull ElementBounds bounds, @NotNull @NotNull Text message) throws IllegalArgumentException
      Constructs a new text widget with the default padding.
      Parameters:
      bounds - the bounds
      message - the text message
      Throws:
      IllegalArgumentException - if message is null
    • FocusedTextWidget

      public FocusedTextWidget(@NotNull @NotNull ElementBounds bounds, @NotNull @NotNull Text message, boolean alwaysShowBorder) throws IllegalArgumentException
      Constructs a new text widget with the default padding.
      Parameters:
      bounds - the bounds
      message - the text message
      alwaysShowBorder - whether to render a drop shadow
      Throws:
      IllegalArgumentException - if message is null
    • FocusedTextWidget

      public FocusedTextWidget(@NotNull @NotNull ElementBounds bounds, @NotNull @NotNull Text message, boolean alwaysShowBorder, int padding) throws IllegalArgumentException
      Constructs a new text widget.
      Parameters:
      bounds - the bounds
      message - the text message
      alwaysShowBorder - whether to render a drop shadow
      padding - the padding around the text
      Throws:
      IllegalArgumentException - if padding is negative or message is null
    • FocusedTextWidget

      public FocusedTextWidget(int x, int y, int width, int height, @NotNull @NotNull Text message)
      Constructs a new text widget.
      Parameters:
      x - the x-coordinate
      y - the y-coordinate
      width - the width
      height - the height
      message - the text message
      Throws:
      IllegalArgumentException - if coordinates or dimensions are negative, or message is null
    • FocusedTextWidget

      public FocusedTextWidget(int x, int y, int width, int height, @NotNull @NotNull Text message, boolean alwaysShowBorder)
      Constructs a new text widget with the default padding.
      Parameters:
      x - the x-coordinate
      y - the y-coordinate
      width - the width
      height - the height
      message - the text message
      alwaysShowBorder - whether to render a drop shadow
      Throws:
      IllegalArgumentException - if coordinates or dimensions are negative, or message is null
    • FocusedTextWidget

      public FocusedTextWidget(int x, int y, int width, int height, @NotNull @NotNull Text message, boolean alwaysShowBorder, int padding) throws IllegalArgumentException
      Constructs a new text widget.
      Parameters:
      x - the x-coordinate
      y - the y-coordinate
      width - the width
      height - the height
      message - the text message
      alwaysShowBorder - whether to render a drop shadow
      padding - the padding around the text
      Throws:
      IllegalArgumentException - if coordinates, dimensions, or padding are negative, or message is null
    • FocusedTextWidget

      public FocusedTextWidget(int x, int y, int width, int height, @NotNull @NotNull String messageJSON, boolean alwaysShowBorder, int padding) throws IllegalArgumentException
      Constructs a new text widget.
      Parameters:
      x - the x-coordinate
      y - the y-coordinate
      width - the width
      height - the height
      messageJSON - the text message as a JSON string
      alwaysShowBorder - whether to render a drop shadow
      padding - the padding around the text
      Throws:
      IllegalArgumentException - if coordinates, dimensions, or padding are negative, or message is null
  • Method Details

    • isAlwaysShowBorder

      public boolean isAlwaysShowBorder()
      Gets whether this text widget should always show its border.
      Returns:
      Whether to always show the border
    • setAlwaysShowBorder

      public void setAlwaysShowBorder(boolean alwaysShowBorder)
      Sets whether this text widget should always show its border.
      Parameters:
      alwaysShowBorder - Whether to always show the border
    • getPadding

      public int getPadding()
      Gets the padding around the text.
      Returns:
      Text Padding
    • setPadding

      public void setPadding(int padding)
      Sets the padding around the text.
      Parameters:
      padding - Text Padding