Oracle JavaFXTableView仅显示空行

Oracle JavaFXTableView仅显示空行,oracle,javafx,tableview,Oracle,Javafx,Tableview,因此,我正在努力使用TableView,在将ObservableList设置为它之后,我得到的行是空白的。我想这与错误的属性绑定有关,但我已经尝试了很多方法,但仍然没有成功。 代码有点类似于oracle的示例: 我的代码: StartingListsTabController.java: package matchescreation.presentation.startingListsTab; import java.net.URL; import java.util.ResourceBund

因此,我正在努力使用TableView,在将ObservableList设置为它之后,我得到的行是空白的。我想这与错误的属性绑定有关,但我已经尝试了很多方法,但仍然没有成功。 代码有点类似于oracle的示例:

我的代码:

StartingListsTabController.java:

package matchescreation.presentation.startingListsTab;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;

import matchescreation.model.CurrentTournament;
import matchescreation.model.InvoiceEntry;

public class StartingListsTabController implements Initializable {
@FXML
private TableView<InvoiceEntry> table;
@FXML
private TableColumn<InvoiceEntry, String> colFirstName;
@FXML
private TableColumn<InvoiceEntry, String> colLastName;
@FXML
private ObservableList<InvoiceEntry> dataArray;

@Override
public void initialize(URL location, ResourceBundle resources) {
    table.setColumnResizePolicy(p -> true);
    table.setSortPolicy(e -> false);

    dataArray = FXCollections.observableArrayList();
    table.setItems(dataArray);

    fillInTable();
}

public void fillInTable() {
    InvoiceEntry i = new InvoiceEntry();
    i.setFirstName("aa");
    i.setLastName("bbb");
    dataArray.add(i);

    InvoiceEntry i2 = new InvoiceEntry();
    i2.setFirstName("2aa");
    i2.setLastName("2bbb");
    dataArray.add(i2);
}
}
和StartingListsTab.fxml:



我刚刚对此进行了测试,无法重现该问题。您添加到
表视图的2行显示在UI中…当我阅读您的响应时,我想到了一些事情,您无法检查。我在css文件中有一些东西-。-“非常感谢!”
package matchescreation.model;

import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;

public class InvoiceEntry {

    private StringProperty firstName;
    private StringProperty lastName;

    public void setFirstName(String value) {
        firstNameProperty().set(value);
    }

    public String getFirstName() {
        return firstNameProperty().get();
    }

    public StringProperty firstNameProperty() {
        if (firstName == null) {
            firstName = new SimpleStringProperty(this, "firstName");
        }
        return firstName;
    }

    public void setLastName(String value) {
        lastNameProperty().set(value);
    }

    public String getLastName() {
        return lastNameProperty().get();
    }

    public StringProperty lastNameProperty() {
        if (lastName == null) {
            lastName = new SimpleStringProperty(this, "lastName");
        }
        return lastName;
    }
}