Class CheckBoxField

java.lang.Object
ca.corbett.forms.fields.FormField
ca.corbett.forms.fields.CheckBoxField

public final class CheckBoxField extends FormField
A FormField to wrap a JCheckBox.

A note about validation: checkboxes don't generally "count" when a FormPanel validates itself. That is, they won't show a validation label to indicate that the selected value is "correct". You can change this behavior by using addFieldValidator() - if any FieldValidators are present on this field, then it will be included when the FormPanel is validated.

Getting access to the underlying JCheckBox - if you need access to the underlying JCheckBox (for example, for styling purposes, changing the font, etc), you can use getFieldComponent() and cast the return to JCheckBox.

Since:
2019-11-27
Author:
scorbo2
  • Constructor Details

    • CheckBoxField

      public CheckBoxField(String labelText, boolean isChecked)
  • Method Details

    • hasValidationLabel

      public boolean hasValidationLabel()
      Overridden here as we generally don't want to show a validation label on a checkbox. Will return true only if one or more FieldValidators have been explicitly assigned.
      Overrides:
      hasValidationLabel in class FormField
    • isChecked

      public boolean isChecked()
    • setChecked

      public CheckBoxField setChecked(boolean checked)