我可以在表格单元格中设置一个微调器。
但问题是,当我使用 getSelectionModel() 时,我无法获取该值。
有什么办法可以做到这一点吗?
我当前使用的代码是这样的:
QuantitaCol.setCellValueFactory(new PropertyValueFactory<Strumento, Integer>("Quantita_Disp"));
QuantitaCol.setCellFactory(new Callback<TableColumn<Strumento,Integer>,TableCell<Strumento,Integer>>(){
@Override
public TableCell<Strumento, Integer> call(TableColumn<Strumento, Integer> param) {
TableCell<Strumento, Integer> cell = new TableCell<Strumento, Integer>(){
@Override
public void updateItem(Integer item, boolean empty) {
if(item!=null){
Spinner<Integer> quantita = new Spinner<Integer>(0, item, 1);
quantita.valueProperty().addListener(
(obs, oldValue, newValue) -> {
System.out.println("New value: "+item);
}
);
setGraphic(quantita);
}
}
};
return cell;
}
});
Run Code Online (Sandbox Code Playgroud)