Class CheckboxWidget

java.lang.Object
com.avrix.ui.widgets.Widget
com.avrix.ui.widgets.CheckboxWidget

public class CheckboxWidget extends Widget
A Widget that represents a checkbox with a title and an icon. The checkbox can be checked or unchecked, and the title text can be truncated with an ellipsis if it exceeds the maximum width.
  • Constructor Details

    • CheckboxWidget

      public CheckboxWidget(String title, int x, int y, int width, int height, Consumer<Boolean> onCheckAction)
      Constructs a new Widget with the specified position and size.
      Parameters:
      title - the title text for the Widget
      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
      onCheckAction - the action to perform when the checkbox is checked or unchecked
  • Method Details

    • onLeftMouseUp

      public void onLeftMouseUp(int x, int y)
      Handles the left mouse button release event to toggle the checkbox state.
      Overrides:
      onLeftMouseUp in class Widget
      Parameters:
      x - the x-coordinate of the mouse event
      y - the y-coordinate of the mouse event
    • getTitleText

      public final String getTitleText()
      Returns the title text for the checkbox.
      Returns:
      the title text
    • setTitleText

      public final void setTitleText(String titleText)
      Sets the title text for the checkbox.
      Parameters:
      titleText - the title text to set
    • getFontName

      public final String getFontName()
      Returns the font name used for the title text.
      Returns:
      the font name
    • setFontName

      public final void setFontName(String fontName)
      Sets the font name used for the title text.
      Parameters:
      fontName - the font name to set
    • getCheckIcon

      public final String getCheckIcon()
      Returns the icon used to represent a checked state.
      Returns:
      the check icon
    • setCheckIcon

      public final void setCheckIcon(String checkIcon)
      Sets the icon used to represent a checked state.
      Parameters:
      checkIcon - the check icon to set
    • getIconFontName

      public final String getIconFontName()
      Returns the font name used for the checkbox icon.
      Returns:
      the icon font name
    • setIconFontName

      public final void setIconFontName(String iconFontName)
      Sets the font name used for the checkbox icon.
      Parameters:
      iconFontName - the icon font name to set
    • getCheckBoxSize

      public final int getCheckBoxSize()
      Returns the size of the checkbox.
      Returns:
      the checkbox size
    • setCheckBoxSize

      public final void setCheckBoxSize(int checkBoxSize)
      Sets the size of the checkbox.
      Parameters:
      checkBoxSize - the checkbox size to set
    • getFontSize

      public final int getFontSize()
      Returns the font size used for the title text.
      Returns:
      the font size
    • setFontSize

      public final void setFontSize(int fontSize)
      Sets the font size used for the title text.
      Parameters:
      fontSize - the font size to set
    • getTitleOffset

      public final int getTitleOffset()
      Returns the offset between the checkbox and the title text.
      Returns:
      the title offset
    • setTitleOffset

      public final void setTitleOffset(int titleOffset)
      Sets the offset between the checkbox and the title text.
      Parameters:
      titleOffset - the title offset to set
    • isChecked

      public final boolean isChecked()
      Returns whether the checkbox is currently checked.
      Returns:
      true if the checkbox is checked, false otherwise
    • setChecked

      public final void setChecked(boolean checked)
      Sets whether the checkbox is currently checked.
      Parameters:
      checked - true to check the checkbox, false to uncheck it
    • isEnable

      public final boolean isEnable()
      Returns whether the checkbox is enabled.
      Returns:
      true if the checkbox is enabled, false otherwise
    • setEnable

      public final void setEnable(boolean enable)
      Sets whether the checkbox is enabled.
      Parameters:
      enable - true to enable the checkbox, false to disable it
    • getTitleColor

      public final NanoColor getTitleColor()
      Returns the color of the title text.
      Returns:
      the title color
    • setTitleColor

      public final void setTitleColor(NanoColor titleColor)
      Sets the color of the title text.
      Parameters:
      titleColor - the title color to set
    • getCheckColor

      public final NanoColor getCheckColor()
      Returns the color of the checkbox icon when checked.
      Returns:
      the check color
    • setCheckColor

      public final void setCheckColor(NanoColor checkColor)
      Sets the color of the checkbox icon when checked.
      Parameters:
      checkColor - the check color to set
    • setOnCheckAction

      public void setOnCheckAction(Consumer<Boolean> onCheckAction)
      Sets the action to perform when the checkbox is checked or unchecked.
      Parameters:
      onCheckAction - the action to perform
    • render

      public void render()
      Renders the Widget
      Specified by:
      render in class Widget