Reputation: 1
So I have this TreeTableView and I can get text to display properly but buttons and images don't want to display. I'm currently using the method of overriding the TreeTableCell class and its update method.
TreeTableColumn<Application, Application> installed = new TreeTableColumn<Application, Application>("Installed?");
installed.setResizable(false);
installed.setPrefWidth(308.9);
installed.setCellFactory(new Callback<TreeTableColumn<Application, Application>, TreeTableCell<Application, Application>>()
{
@Override
public TreeTableCell<Application, Application> call(TreeTableColumn<Application, Application> param)
{
TreeTableCell<Application, Application> cell = new TreeTableCell<Application, Application>()
{
@Override
public void updateItem(Application app, boolean empty)
{
if(app != null)
{
setGraphic(app.getInstalledImage());
}
}
};
return cell;
}
});
appTree.getColumns().add(installed);
However, "app" throws a NullPointerException when not checking for app != null so I'm thinking that may fix my problem. Any ideas why a valid Application is not getting passed?
Upvotes: 0
Views: 720
Reputation: 209319
The TreeTableView
contains empty cells; cells in the space below the last populated row and, perhaps, cells in some columns for collapsed rows. Empty cells always have updateItem(...)
called with a null
item.
Note that it's always essential to call super.updateItem(...)
in your implementation:
@Override
public void updateItem(Application app, boolean empty)
{
super.updateItem(app, empty);
if(app != null)
{
setGraphic(app.getInstalledImage());
}
}
See the Javadocs for Cell
for details.
Upvotes: 1