Tableview javaFX - getColumns() 的类型是错误的

Tableview javaFX - The type of getColumns() is eroneous

我遇到了一个 getColumns 错误问题,我自己也搞不懂。我没有运气就在互联网上搜索过。我希望你们中的一些人对此有一个很好的答案!因为我卡住了...

我创建了一个 Create Member 场景,我想在创建后将信息存储在 TableView 中。我制作了一个名为 Person 的 class 来制作 getter 和 setter。

在我的 TableView class 中,我制作了一个 TableView ArrayList,它应该包含对象,但没有成功!

代码如下,希望能帮到你。 对不起,不好的解释。我又累又生气 :D

public class Members extends DelfinenProjekt
{


 DelfinenProjekt df = new DelfinenProjekt();

private TableView<Person> tableMembers = new TableView<Person>();
private final Label memberLabel = new Label("Brugeroversigt");
private final VBox vbox = new VBox();
private final ObservableList<Person> memberData = FXCollections.observableArrayList(new Person(firstnameTextField.getText(), 
                                                                                         lastnameTextField.getText(), 
                                                                                         ageTextField.getText(), 
                                                                                         addressTextField.getText(),
                                                                                         cityTextField.getText(),
                                                                                         emailMedlemTextField.getText(),
                                                                                         cprNoTextField.getText()));

public Scene members()
{
    BorderPane border = new BorderPane();
    border.setCenter(tableMembers);
    memberLabel.setFont(new Font("Tahoma", 20));

    tableMembers.setEditable(true);
//        Creating table menu with coloums
        TableColumn firstnameColoum = new TableColumn("Firstname");
        firstnameColoum.setMaxWidth(100);
        firstnameColoum.setCellValueFactory(new PropertyValueFactory<Person, String>("firstName"));

        TableColumn lastnameColoum = new TableColumn("Lastname");
        lastnameColoum.setMaxWidth(100);
        lastnameColoum.setCellValueFactory(new PropertyValueFactory<Person, String>("lastName"));

        TableColumn ageColoum = new TableColumn("Age");
        ageColoum.setMaxWidth(100);
        ageColoum.setCellValueFactory(new PropertyValueFactory<Person, String>("age"));

        TableColumn addressColoum = new TableColumn("Address");
        addressColoum.setMaxWidth(100);
        addressColoum.setCellValueFactory(new PropertyValueFactory<Person, String>("address"));

        TableColumn cityColoum = new TableColumn("City");
        cityColoum.setMaxWidth(100);
        cityColoum.setCellValueFactory(new PropertyValueFactory<Person, String>("city"));

        TableColumn emailColoum = new TableColumn("Email");
        emailColoum.setMaxWidth(100);
        emailColoum.setCellValueFactory(new PropertyValueFactory<Person, String>("email"));

        TableColumn cprColoum = new TableColumn("CPR number");
        cprColoum.setMaxWidth(100);
        cprColoum.setCellValueFactory(new PropertyValueFactory<Person, String>("cprNo"));


//        Adding them to the getColoums in TableView
        tableMembers.setItems(memberData);
        tableMembers.getColumns().addAll(firstnameColoum, lastnameColoum, ageColoum, addressColoum, cityColoum, emailColoum, cprColoum);

        vbox.setSpacing(5);
        vbox.setPadding(new Insets(10));
        vbox.getChildren().addAll(memberLabel, tableMembers);



        Scene scene = new Scene(new Group(border), 640, 480);
        ((Group) scene.getRoot()).getChildren().addAll(vbox);

        return scene;


    }

}

我的另一个 class,人:

public class Person implements Serializable
 {
private SimpleStringProperty firstName;
private SimpleStringProperty lastName;
private SimpleIntegerProperty age;
private SimpleStringProperty address;
private SimpleStringProperty city;
private SimpleStringProperty email;
private SimpleDoubleProperty cprNo;

public Person(String firstName, String lastName, int age, String address, String city, String email, double cprNo) 
{
    this.firstName = new SimpleStringProperty(firstName);
    this.lastName = new SimpleStringProperty(lastName);
    this.age = new SimpleIntegerProperty(age);
    this.address = new SimpleStringProperty(address);
    this.city = new SimpleStringProperty(city);
    this.email = new SimpleStringProperty(email);
    this.cprNo = new SimpleDoubleProperty(cprNo);
}

public SimpleStringProperty getFirstName() {
    return firstName;
}

public void setFirstName(SimpleStringProperty firstName) {
    this.firstName = firstName;
}

public SimpleStringProperty getLastName() {
    return lastName;
}

public void setLastName(SimpleStringProperty lastName) {
    this.lastName = lastName;
}

public SimpleIntegerProperty getAge() {
    return age;
}

public void setAge(SimpleIntegerProperty age) {
    this.age = age;
}

public SimpleStringProperty getAddress() {
    return address;
}

public void setAddress(SimpleStringProperty address) {
    this.address = address;
}

public SimpleStringProperty getCity() {
    return city;
}

public void setCity(SimpleStringProperty city) {
    this.city = city;
}

public SimpleStringProperty getEmail() {
    return email;
}

public void setEmail(SimpleStringProperty email) {
    this.email = email;
}

public SimpleDoubleProperty getCprNo() {
    return cprNo;
}

public void setCprNo(SimpleDoubleProperty cprNo) {
    this.cprNo = cprNo;
}



}

希望你能帮助我! 问题出在:tableMembers.getColoums().addAll()

此致, 亚历山大

尝试 TableColumn<Person,String> 而不是 TableColumn