Javafx tableview with data from multiple classes

后端 未结 2 1441
迷失自我
迷失自我 2020-12-20 06:45

I have no problem filling my tableview with diffrent data from 1 class. But it does not work for me with multiple classes. Any idea how to solve that? I have checked out sim

2条回答
  •  攒了一身酷
    2020-12-20 07:09

    Solved it by adding an additional String to my TaskControl, that contains the names of all the projects it contains. It gets the names through a function that I call just before I create the ObservableList for the Table Column.

    private String projectsAsString;
        ...
    public final void convertProjectsToString() {
    
        String projects = "";
    
        for (Project p : this.getProjects()) {
            ProjectControl pp = (ProjectControl) p;
            projects += pp.getName() + ", ";
        }
        if (projects != null && projects != "" && projects.length() > 4) {
            projects = projects.substring(0, projects.length() - 2);
        }
        this.projectsAsString = projects;
    }
    

    Thank you guys anyways for helping me.

提交回复
热议问题