如何将复选框添加到FormLayout(Vaadin)中



我正试图将checkbox添加到FormLayout中,但它抛出了一个警告:

我的代码

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);
}

问题是这一行:

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

显示警告:

Required type: Component
Provided: Checkbox

是否可以在FormLayout中添加复选框?

听起来您导入了错误的复选框。确保导入为com.vaadin.flow.component.checkbox.Checkbox

相关内容

  • 没有找到相关文章

最新更新