[英]JavaFX TableView edit integer cell
在JavaFX的官方文檔中編輯數據一個表視圖,只有String的例子,在我的程序中我有兩個INTEGER列,我用它來編輯它們:選擇行,單擊按鈕,新表單顯示,用戶之后填寫它,點擊確定,然后數據更改。 現在我想從這里轉移到表中的直接輸入。 如何使用整數列執行此操作。
TreeTableColumn<RootMaster, Integer> dataColumn = new TreeTableColumn<>(rs.getString("tab.budget.table.column.budgeted"));
dataColumn.setEditable(true);
dataColumn.setCellValueFactory(new TreeItemPropertyValueFactory<RootMaster, Integer>("budgetSum"));
dataColumn.setCellFactory(col -> {
TreeTableCell<RootMaster, Integer> cell = new TreeTableCell<RootMaster, Integer>() {
@Override
public void updateItem(Integer item, boolean empty) {
super.updateItem(item, empty);
if (empty) {
setText(null);
} else {
setText(item.toString());
}
}
};
cell.setAlignment(Pos.CENTER);
return cell;
});
謝謝
你可以做
dataColumn.setCellFactory(
TextFieldTreeTableCell.forTreeTableColumn(new IntegerStringConverter()));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.