【发布时间】:2019-07-27 14:14:10
【问题描述】:
我正在尝试使用Java 8 为ControlsFX CheckComboBox v8.0.3 设置默认选定值
我已经在this question 中尝试了接受的答案,但是当我尝试时
CheckComboBox.getCheckModel().check(0);
我得到一个类不能从静态上下文中引用。当我尝试以下操作时,我无法解析方法 check(int);
final CheckComboBox<String> checkComboBox = new CheckComboBox<>(strings);
checkComboBox.getCheckModel().check(0);
如果我尝试getCheckmodel().selectIndices(0),则仅当从CheckComboBox 中选择新值时,第一个All1 才会填充到CheckComboBox。选择索引后有没有办法刷新comboxBox 或任何其他方式来实现我想要的?
Text numberTypeText = new Text("Features supported:");
final ObservableList<String> strings = FXCollections.observableArrayList();
strings.add("All1");
strings.add("All2");
strings.add("All3");
strings.add("All4");
strings.add("All5");
strings.add("All6");
strings.add("All7");
strings.add("All8");
final CheckComboBox<String> checkComboBox = new CheckComboBox<>(strings);
checkComboBox.getCheckModel().selectIndices(0);
checkComboBox.getCheckModel().getSelectedItems().addListener(new ListChangeListener<String>() {
public void onChanged(ListChangeListener.Change<? extends String> c) {
System.out.println(checkComboBox.getCheckModel().getSelectedItems());
}
});
任何帮助将不胜感激。
【问题讨论】:
标签: java javafx controlsfx