Skip to content

CheckBoxContainer ​

com.jsmacrosce.wagyourgui.containers.CheckBoxContainer

A checkbox-and-label container for WagYourGUI; construction registers its checkbox with the supplied parent,
while the host must arrange this container's label hook separately. Activation toggles the stored state,
calls the optional consumer with the new boolean, then updates the checkmark after a normal callback return.
If the callback throws, the state has changed but the checkmark update is not reached; without a callback both updates proceed.
The factory takes a caller-supplied IContainerParent, native Font, native Component label and JavaScript callback:

js
function makeCheckBox(parent, font, label, onChanged) {
 const CheckBoxContainer = Java.type('com.jsmacrosce.wagyourgui.containers.CheckBoxContainer');  
 return new CheckBoxContainer(10, 10, 140, 14, font, false, label, parent, JavaWrapper.methodToJava(onChanged));  
}

Constructors ​

new CheckBoxContainer ​

new CheckBoxContainer(int x, int y, int width, int height, Font textRenderer, boolean defaultState, Component message, IContainerParent parent, Consumer<Boolean> setState)#
Stores the checkbox configuration and immediately initializes and registers its button with parent; no callback is invoked during construction.

Parameters:

  • x: left coordinate in the GUI
  • y: top coordinate in the GUI
  • width: total container width, including the label region
  • height: checkbox side length and label offset
  • textRenderer: non-null font used for the checkbox and label
  • defaultState: initial checked state
  • message: non-null native component used as the label
  • parent: non-null widget host that registers the checkbox
  • setState: optional consumer called with the new checked state on button activation

Fields ​

message ​

message: Component#
Non-null native label reference read by each visible label hook; replacing it changes later label submissions, not checkbox state or its checkmark. The constructor stores the supplied reference without copying.

Methods ​

extractRenderState ​

extractRenderState(GuiGraphicsExtractor drawContext, int mouseX, int mouseY, float delta): void#
Submits only the current label when this container is visible, using word wrapping at (x + height, y + 2) with width width - height - 2 from the stored container geometry. Does not submit the checkbox or forward the hook to children; the parent handles the separately registered checkbox. Mouse and frame parameters are unused.

Parameters:

  • drawContext: graphics context receiving the label
  • mouseX: unused GUI mouse coordinate
  • mouseY: unused GUI mouse coordinate
  • delta: unused frame value

init ​

init(): void#
Clears local button tracking and registers a new checkbox at the stored position with the stored height as its side length. Retains the current checked state, replaces the checkbox reference and does not invoke the state consumer. Prior parent registrations are not removed; the constructor already calls this method.

setPos ​

setPos(int x, int y, int width, int height): void#
Moves and resizes only the checkbox to (x + 1, y + 1, height - 2, height - 2). Stored container geometry and label placement are unchanged, and width is unused. Reinitialization uses the stored container geometry again.

Parameters:

  • x: supplied outer left coordinate
  • y: supplied outer top coordinate
  • width: unused
  • height: supplied outer height, determining the inset checkbox side