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
?
CodePudding user response:
Sounds like you are importing the wrong Checkbox. Make sure the import is com.vaadin.flow.component.checkbox.Checkbox
.