I'm having troubles accessing the objects displayed in the TableColumn
Here's the code snippet where I set the graphics of one Column. Only want to show the Name of the Person object: (Any better/easier way in doing that is welcome)
ownerColumn
.setCellFactory(new Callback<TableColumn<Site, Person>, TableCell<Site, Person>>() {
@Override
public TableCell<Site, Person> call(
TableColumn<Site, Person> param) {
TableCell<Site, Person> ownerCell = new TableCell<Site, Person>() {
@Override
protected void updateItem(Person item, boolean empty) {
if (item != null) {
Label label = new Label(item.getName());
setGraphic(label);
}
}
};
return ownerCell;
}
});
Now I'm trying to loop through the rows and columns go get every cell to generate a report at the end, reflecting the displayed text/graphics in the Tableview. Like this
for (Object r : this.tableview.getItems()) {
for (Object c : this.tableview.getColumns()) {
javafx.scene.control.TableColumn column = (javafx.scene.control.TableColumn) c;
if (column.getCellData(r) != null) {
// I get the object bound to the cell here, but I only want
// to have what i've set as graphics - what the user sees on UI
// How to use getGraphics() ?
}
}
}
So the question is, how do I get the getGraphics() I've set in the CellFactory?