2016-05-13 66 views
0

我想将复选框和文本字段添加到PropertySheetControlsFX库)的一个属性中。可能或不可以?所以,我只需要将一些GUI元素添加到一个PropertyEditor,例如复选框+按钮,复选框+标签,复选框+文本框等。是否可以覆盖PropertyEditor来执行此操作?PropertySheet Editor中的多个场景节点JavaFX

enter image description here enter image description here

+0

是的cource是可能的! –

回答

0

由我自己解决。我试图将复选框+组合框添加到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); 
     } 
    }; 
} 
0

,你也可以换一个单亲家庭里的倍数节点。[见这里][1]