如何在TableView的列中自定义渲染
//定义TableView中的列TableColumn<FieldDefine, FieldDefine.Type> fieldTypeCol = new TableColumn<>(); fieldTypeCol.setText(LanguageHelper.getString("common.field_type")); fieldTypeCol.setPrefWidth(100); fieldTypeCol.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<FieldDefine, FieldDefine.Type>, ObservableValue<FieldDefine.Type>>() { @Override public ObservableValue<FieldDefine.Type> call(TableColumn.CellDataFeatures<FieldDefine, FieldDefine.Type> fieldDefineTypeCellDataFeatures) { return new ReadOnlyObjectWrapper(fieldDefineTypeCellDataFeatures.getValue().getType().getValue()); } });
public class FieldDefine { protected String labelName; protected String name; protected FieldDefine.Type type; static class Type { protected FieldType value; FieldType getValue() { return value; } void setValue(FieldType value) { this.value = value; } } public String getLabelName() { return labelName; } public void setLabelName(String labelName) { this.labelName = labelName; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Type getType() { return type; } public void setType(Type type) { this.type = type; }}