Class CheckBox

All Implemented Interfaces:
IRenderable, Tweenable, MouseListener, MouseMotionListener, MouseWheelListener, EventListener

public class CheckBox extends ImageComponent
A GUI component representing a checkbox with an optional spritesheet.
  • Field Details

    • CHECK

      public static final FontIcon CHECK
      The icon representing a checked state.
    • CROSS

      public static final FontIcon CROSS
      The icon representing an unchecked state.
  • Constructor Details

    • CheckBox

      public CheckBox(double x, double y, double width, double height, Spritesheet spritesheet, boolean checked)
      Constructs a new CheckBox.
      Parameters:
      x - the x-coordinate of the checkbox
      y - the y-coordinate of the checkbox
      width - the width of the checkbox
      height - the height of the checkbox
      spritesheet - the spritesheet for the checkbox
      checked - the initial checked state of the checkbox
  • Method Details

    • getChangeConsumer

      public List<Consumer<Boolean>> getChangeConsumer()
      Gets the list of consumers to be notified when the checked state changes.
      Returns:
      the list of change consumers
    • isChecked

      public boolean isChecked()
      Checks if the checkbox is currently checked.
      Returns:
      true if the checkbox is checked, false otherwise
    • onChange

      public void onChange(Consumer<Boolean> c)
      Adds a consumer to be notified when the checked state changes.
      Parameters:
      c - the consumer to be added
    • setChecked

      public void setChecked(boolean checked)
      Sets the checked state of the checkbox.
      Parameters:
      checked - the new checked state