我尝试使用组合框和重置按钮构建一个简单表单。我想丢弃我可以重置组合框。我做错了什么?未注释的 combobox.select 是一种解决方法。
按照简单的例子:
public class VaadinprojectApplication extends Application {
@Override
public void init() {
final Window mainWindow = new Window("Simpleform");
final List<String> aListWithStrings = new ArrayList<String>();
aListWithStrings.add("Somthing");
final BeanItemContainer<String> objects = new BeanItemContainer<String>(String.class, aListWithStrings);
final ComboBox comboBox = new ComboBox("Importers", objects);
// reset button
final Button resetButton = new Button("Reset", new Button.ClickListener() {
@Override
public void buttonClick(final ClickEvent event) {
// comboBox.select(comboBox.getNullSelectionItemId());
comboBox.discard();
System.out.println("reset");
}
});
final FormLayout form = new FormLayout();
form.addComponent(comboBox);
form.addComponent(resetButton);
form.setSizeUndefined();
mainWindow.addComponent(form);
setMainWindow(mainWindow);
}
}