0
所以我有這TreeTableView,我可以讓文本正常顯示,但按鈕和圖像不想顯示。我目前正在使用重寫TreeTableCell類及其更新方法的方法。JavaFX 8 - 添加組件到TreeTable單元
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);
但是,「應用程序」拋出一個NullPointerException異常時不檢查應用程序!= NULL,所以我想,可以解決我的問題。任何想法爲什麼一個有效的應用程序沒有通過?