![](/img/trans.png)
[英]automatically resize TableColumn of TableColumn in TableView with JavaFX -8
[英]How to add two buttons in a TableColumn of TableView JavaFX
我想在动作TableColumn中添加两个按钮,我已经阅读了此如何在JavaFX表格视图中添加按钮,以及如何 在TableView(JAVAFX)的单元格中添加按钮,但是它们都使用setGraphic
一个按钮,所以当我尝试时使用:
actionFld.setCellFactory(param -> new TableCell<Patient, Patient>() {
private final JFXButton editButton = new JFXButton("edit");
private final JFXButton deleteButton = new JFXButton("delete");
@Override
protected void updateItem(Patient patient, boolean empty) {
super.updateItem(patient, empty);
if (patient == null) {
setGraphic(null);
return;
}
deleteButton.setOnAction(event -> {
Patient getPatient = getTableView().getItems().get(getIndex());
System.out.println(getPatient.getNom() + " " + getPatient.getPrenom());
});
editButton.setOnAction(event -> {
Patient getPatient = getTableView().getItems().get(getIndex());
System.out.println(getPatient.getNom() + " " + getPatient.getPrenom());
});
setGraphic(deleteButton);//<<<---------------add button 1
setGraphic(editButton);//<<------------------add button 2
}
});
它只显示一个按钮:
我怎么解决这个问题?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.