Center text in a table once a button has been added dynamically
Davide Perini
perini.davide at dpsoftware.org
Mon Aug 14 13:34:20 UTC 2023
Hi all,
hope that someone can help with this :)
I have a TableView like this:
If I add a remove button in the table like this:
private TableColumn<Satellite, Void>getSatelliteVoidTableColumn() {
TableColumn<Satellite, Void> colBtn =new TableColumn<>("");
colBtn.setMaxWidth(Constants.REMOVE_BTN_TABLE);
Callback<TableColumn<Satellite, Void>, TableCell<Satellite, Void>> cellFactory =new Callback<>() {
@Override public TableCell<Satellite, Void>call(final TableColumn<Satellite, Void> param) {
return new TableCell<>() {
private final Buttonbtn =new Button(Constants.UNICODE_X);
{
btn.setOnAction((ActionEvent event) -> {
Satellite data = getTableView().getItems().get(getIndex());
populateFields(data);
satellitesTableData.remove(data);
});
}
@Override public void updateItem(Void item,boolean empty) {
super.updateItem(item, empty);
if (empty) {
setGraphic(null);
}else {
setGraphic(btn);
}
}
};
}
};
colBtn.setCellFactory(cellFactory);
return colBtn;
}
TableColumn<Satellite, Void> colBtn = getSatelliteVoidTableColumn();
satelliteTable.getColumns().add(0, colBtn);
The text inside the cell of the table is not vertically centered.
How can I center it?
Thanks
Davide
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20230814/dba60018/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: HG803qbXjbva061F.png
Type: image/png
Size: 56596 bytes
Desc: not available
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20230814/dba60018/HG803qbXjbva061F-0001.png>
More information about the openjfx-dev
mailing list