lundi 5 septembre 2022

How to add checkbox into FormLayout (Vaadin)

I am trying to add the checkbox into the FormLayout, but it throwing an warning:

My code

private void createEditorLayout(SplitLayout splitLayout) {

    Div editorLayoutDiv = new Div();
    editorLayoutDiv.setClassName("editor-layout");

    Div editorDiv = new Div();
    editorDiv.setClassName("editor");
    editorLayoutDiv.add(editorDiv);

    FormLayout formLayout = new FormLayout();
    monthAndYear = new DatePicker("Month and year");
    organizationId = new TextField("Organiziation ID");
    userId = new TextField("User ID");
    onlyForOrganization = new Checkbox("Only for organization");

    Component[] fields = new Component[]{monthAndYear, onlyForOrganization, organizationId, userId}; 

    formLayout.add(fields);
    editorDiv.add(formLayout);
    createButtonLayout(editorLayoutDiv);
    splitLayout.addToSecondary(editorLayoutDiv);

}

The problematic is this row:

Component[] fields = new Component[]{monthAndYear, onlyForOrganization, organizationId, userId}; 

It showing warning:

Required type: Component
Provided: Checkbox

Is it possible to somehow add a checkbox to the FormLayout?




Aucun commentaire:

Enregistrer un commentaire