I don't know how to add image in JFXTreeTableView because when I set my variable type to ImageView I get an error that I should give it String data. This is my class and constructor:
class TeamsInnerClass extends RecursiveTreeObject<TeamsInnerClass> {
ImageView icon;
SimpleStringProperty teamName;
...
public TeamsInnerClass(ImageView icon, String teamName) {
this.icon = icon;
this.teamName = new SimpleStringProperty(teamName);
}
}
This is the controller:
JFXTreeTableColumn<TeamsInnerClass, ImageView> icon = new JFXTreeTableColumn<>();
icon.setPrefWidth(100);
icon.setCellValueFactory(param -> param.getValue().getValue().icon);
JFXTreeTableColumn<TeamsInnerClass, String> teamName = new JFXTreeTableColumn<>("Teams");
teamName.setPrefWidth(100);
teamName.setCellValueFactory(param -> param.getValue().getValue().teamName);
...
and the data that is made with constructor:
ObservableList<TeamsInnerClass> teamsInnerClass = FXCollections.observableArrayList();
teamsInnerClass.add(new TeamsInnerClass(new ImageView(new Image("League/backs/background2.jpg")), "Real"));
final TreeItem<TeamsInnerClass> root = new RecursiveTreeItem<>(teamsInnerClass, RecursiveTreeObject::getChildren);
scoresTable.getColumns().addAll(icon, teamName);
scoresTable.setRoot(root);
scoresTable.setShowRoot(false);
and the error that I get: