Checkbox, CheckboxGroup and RadioButtonGroup

Checkbox

The checkbox can be used to easily pass a Boolean value from the user to the program. Due to the simplicity of the checkbox, the value does not need to be validated beforehand.

Important properties:

  • Indeterminate - This property causes the checkbox to be in an indeterminate form after the view is loaded. It means neither true nor false. This way you can be sure that the user really entered the value.

  • Label - description placed next to the checkbox.

  • Value - value that is in the checkbox by default.

CheckboxGroup

The CheckboxGroup can be used to query a whole range of Boolean values. To achieve this, you can proceed as follows:

  1. Drag and drop the CheckboxGroup onto the view.

  2. Drag and drop an entity onto the CheckboxGroup.

  3. Then in the following dialog select where the description that should be next to the checkbox should come from.

  4. Then in the properties under Data > DataProvider select the query which will be used to populate the CheckboxGroup from the database.
    Alternatively: the CheckboxGroup can also be filled by code. To do this, you can extend the constructor of the view as follows:

    public MainLayout()
    {
        super();
        this.initUI();
    
        this.checkboxGroup.setItems(
            new Kunde("Hans", "Robert"),
            new Kunde("Joachim", "Schmidt"),
            new Kunde("Lars", "Sommermann"));
    }
  5. You can then get the selected customers via checkboxGroup.getSelectedItems().

Important properties:

  • Vertical - Rows the checkboxes below each other, instead of next to each other.

RadioButtonGroup

The RadioButtonGroup can be filled in the same way as the CheckboxGroup. The important difference here, however, is that only one value can be selected by the user.

You can get the result via radioButtonGroup.getValue().

Important properties:

  • Vertical - Lining up the RadioButtons below each other, instead of side by side.