This component provides a switchable button that can be toggled between ON and OFF states.
Usage:
SwitchButton button = SwitchButton.create("Label", "Off", "On");
See also :
public void SwitchButton(String label, String offTitle, String onTitle)
label
the label of the switch button
offTitle
the title when switch is OFF
onTitle
the title when switch is ON
public void SwitchButton(String label, String onOffTitle)
label
the label of the switch button
onOffTitle
the title for both ON and OFF states
public void SwitchButton(String label)
label
the label of the switch button
public void SwitchButton()
public static SwitchButton create(String label, String offTitle, String onTitle)
label
the label of the switch button
offTitle
the title when switch is OFF
onTitle
the title when switch is ON
a new SwitchButton instance
public static SwitchButton create(String label, String onOffTitle)
label
the label of the switch button
onOffTitle
the title for both ON and OFF states
a new SwitchButton instance
public static SwitchButton create()
a new SwitchButton instance
public String getType()
String representing the type "checkbox".
public Optional<Consumer<Event>> onChange()
Optional containing a Consumer for the change event.
public SwitchButton toggleChecked(boolean silent)
silent
if true, does not notify the change listeners.
the current instance of SwitchButton .
public SwitchButton toggleChecked()
public SwitchButton toggleChecked(boolean checkedState, boolean silent)
checkedState
desired checked state.
silent
if true, does not notify the change listeners.
the current instance of SwitchButton .
public Boolean getDefaultValue()
the default value which is false if null.
public SwitchButton withValue(Boolean value, boolean silent)
value
the desired value.
silent
if true, does not notify the change listeners.
the current instance of SwitchButton .
public SwitchButton check()
public SwitchButton uncheck()
public SwitchButton check(boolean silent)
silent
if true, does not notify the change listeners.
the current instance of SwitchButton .
public SwitchButton uncheck(boolean silent)
silent
if true, does not notify the change listeners.
the current instance of SwitchButton .
public SwitchButton setOnTitle(String onTitle)
onTitle
the title to be set for the "on" state.
the current instance of SwitchButton .
public SwitchButton setOffTitle(String offTitle)
offTitle
the title to be set for the "off" state.
the current instance of SwitchButton .
public LazyChild<LabelElement> getOffLabelElement()
the LazyChild for the "off" label element.
public LazyChild<LabelElement> getOnLabelElement()
the LazyChild for the "on" label element.
public AutoValidator createAutoValidator(ApplyFunction autoValidate)
autoValidate
the ApplyFunction to be applied for auto-validation.
an instance of AutoValidator for the SwitchButton.
public Boolean getValue()
the Boolean value representing the checked state of the SwitchButton.
public boolean isChecked()
true if the SwitchButton is checked, false otherwise.
public boolean isEmpty()
true if the SwitchButton is empty, false otherwise.
public boolean isEmptyIgnoreSpaces()
true if the SwitchButton is empty, false otherwise.
public String getStringValue()
a string representation of the Boolean value.
public SwitchButton grow()
the current instance of SwitchButton .
public SwitchButton ungrow()
the current instance of SwitchButton .
public SwitchButton grow(boolean grow)
grow
true to add the CSS class and make the SwitchButton grow, false to remove it.
the current instance of SwitchButton .
public SwitchButton condenseLabels()
the current instance of SwitchButton .
public SwitchButton uncondenseLabels()
the current instance of SwitchButton .
public SwitchButton condenseLabels(boolean grow)
grow
true to add the CSS class and condense the labels, false to remove it.
the current instance of SwitchButton .
public String getName()
the name attribute value.
public SwitchButton setName(String name)
name
the name attribute to be set.
the current instance of SwitchButton .