首先让我解释一下我做了什么。
我能够从表中获取列并将其放在tableview中,但我无法将数据与关联列绑定。
我的代码是看
this.tableName = clsComboData.getValue();
System.out.println(tableName); System.out.println("Button Pressed");
List<StaticColumnConfig> allColumns = null;
for(StaticDataTable dataTable : dropdown) {
if(dataTable.getTableName() != null && dataTable.getTableName().equalsIgnoreCase(tableName)) {
System.out.println(dataTable.getColumnConfig());
allColumns = dataTable.getColumnConfig();
}
}
switch (tableName) {
case "IOSwapCounterparties": SimpleDateFormat date = new SimpleDateFormat("2015-04-15");
System.out.println("Into the Switch");
data = FXCollections.observableArrayList(
new IOSwapCounterparties(1,"a","b","c","d","e",date),
new IOSwapCounterparties(1,"aa","bb","cv","dd","es",date),
new IOSwapCounterparties(1,"ad","bd","cd","dc","eb",date),
new IOSwapCounterparties(1,"aw","bw","cr","dt","ey",date),
new IOSwapCounterparties(1,"ag","bt","cy","du","ep",date)
);
break;
}
//System.out.println("Its in ELSE");
//"Invited" column
TableColumn checkboxCol = new TableColumn<Person, Boolean>();
checkboxCol.setText("");
checkboxCol.setMinWidth(50);
checkboxCol.setCellValueFactory(new PropertyValueFactory("checkbox"));
// Create checkboxes
checkboxCol.setCellFactory(new Callback<TableColumn<Person, Boolean>, TableCell<Person, Boolean>>() {
public TableCell<Person, Boolean> call(TableColumn<Person, Boolean> p) {
CheckBoxTableCell<Person, Boolean> checkBox = new CheckBoxTableCell();
return checkBox;
}
});
//Set cell factory for cells that allow editing
Callback<TableColumn, TableCell> cellFactory =
new Callback<TableColumn, TableCell>() {
public TableCell call(TableColumn p) {
return new EditingCell();
}
};
for(StaticColumnConfig column : allColumns){
TableColumn oneColumn = new TableColumn(column.getColumnName());
oneColumn.setCellFactory(cellFactory);
}
// Clear the tableview for next table
tblViewer.getColumns().clear();
// Push the data to the tableview
tblViewer.setItems(data);
tblViewer.setEditable(true);
tblViewer.getColumns().addAll(checkboxCol);
for(StaticColumnConfig column : allColumns){
System.out.println(column.getColumnName());
TableColumn oneColumn = new TableColumn(column.getColumnName());
tblViewer.getColumns().addAll(oneColumn);
}
// Add the columns
tblViewer.getSelectionModel().setCellSelectionEnabled(true);
tblViewer.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
答案 0 :(得分:0)
我的getter和setter方法存在大写 - 小写错误。