javajavafxcontrolsfxpropertysheet

Multiple scene nodes in PropertySheet Editor JavaFX


I want to add checkbox and textfield to one property of PropertySheet (ControlsFX library). Is it possible or no? So, i just need to add some GUI elements together to one PropertyEditor, for example checkbox + button, checkbox + label, checkbox + textfield and etc. Is it possible to override PropertyEditor to do it?

enter image description here enter image description here


Solution

  • Solved by myself. I tried to add checkbox + combobox to HBox. Code below, it works.

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