【问题标题】:Multiple scene nodes in PropertySheet Editor JavaFXPropertySheet Editor JavaFX 中的多个场景节点
【发布时间】:2016-05-13 11:40:49
【问题描述】:
我想将复选框和文本字段添加到PropertySheet(ControlsFX 库)的一个属性。有可能吗?所以,我只需要将一些GUI元素一起添加到一个PropertyEditor,例如复选框+按钮、复选框+标签、复选框+文本字段等。是否可以覆盖PropertyEditor来做到这一点?
【问题讨论】:
标签:
java
javafx
controlsfx
propertysheet
【解决方案2】:
自己解决。我试图将复选框 + 组合框添加到 HBox。下面的代码,它可以工作。
public static final <T> PropertyEditor<?> createCheckBoxLinkEditor(PropertySheet.Item property,
final Collection<T> choices) {
ComboBox<T> comboBox = new ComboBox<T>();
comboBox.setCellFactory((ListView<T> p) -> new ListCell<T>() {
@Override
protected void updateItem(T item, boolean empty) {
super.updateItem(item, empty);
if (item == null || empty) {
} else if (item instanceof Class) {
setText(((Class) item).getSimpleName());
} else {
setText(item.toString());
}
}
});
HBox hbox = new HBox(5);
CheckBox checkBox = new CheckBox();
hbox.getChildren().add(checkBox);
hbox.getChildren().add(comboBox);
//hbox.getA
//comboBox.setConverter(value);
return new AbstractPropertyEditor<T, HBox>(property, hbox) {
{
comboBox.setItems(FXCollections.observableArrayList(choices));
//new AutoCompleteComboBoxListener(comboBox);
new SelectKeyComboBoxListener(comboBox);
}
@Override
protected ObservableValue<T> getObservableValue() {
return comboBox.getSelectionModel().selectedItemProperty();
}
@Override
public void setValue(T value) {
comboBox.getSelectionModel().select(value);
}
};
}