Строки JavaFX TreeTableView исчезли при прокрутке

Я экспериментировал с TreeTableView в JDK 8. После того, как моя программа заработала, я заметил проблему, заключающуюся в том, что при прокрутке строки становились пустыми. Я пробовал все: от сброса видимости ячейки, когда она обновляется, в надежде, что она будет перерисовываться при обновлении, или даже от сброса видимости столбца. Вот тестовый апплет, который я написал, чтобы показать, что при прокрутке для представления таблицы в виде дерева строки становятся пустыми, но для представления таблицы это не так.

public class TableViewTest extends Application{

private TreeTableView treeTable = new TreeTableView();
private TableView regularTable = new TableView();

 public static void main(String[] args) {
        launch(args);
    }

@Override
public void start(Stage stage) throws Exception {

    final ObservableList<Person> data = FXCollections.observableArrayList(
            new Person("Jacob", "Smith", "[email protected]"),
            new Person("Isabella", "Johnson", "[email protected]"),
            new Person("Ethan", "Williams", "[email protected]"),
            new Person("Emma", "Jones", "[email protected]"),
            new Person("Michael", "Brown", "[email protected]"),
            new Person("Jacob", "Smith", "[email protected]"),
            new Person("Isabella", "Johnson", "[email protected]"),
            new Person("Ethan", "Williams", "[email protected]"),
            new Person("Emma", "Jones", "[email protected]"),
            new Person("Michael", "Brown", "[email protected]"),
            new Person("Jacob", "Smith", "[email protected]"),
            new Person("Isabella", "Johnson", "[email protected]"),
            new Person("Ethan", "Williams", "[email protected]"),
            new Person("Emma", "Jones", "[email protected]"),
            new Person("Michael", "Brown", "[email protected]"),
            new Person("Jacob", "Smith", "[email protected]"),
            new Person("Isabella", "Johnson", "[email protected]"),
            new Person("Ethan", "Williams", "[email protected]"),
            new Person("Emma", "Jones", "[email protected]"),
            new Person("Michael", "Brown", "[email protected]"),
            new Person("Jacob", "Smith", "[email protected]"),
            new Person("Isabella", "Johnson", "[email protected]"),
            new Person("Ethan", "Williams", "[email protected]"),
            new Person("Emma", "Jones", "[email protected]"),
            new Person("Michael", "Brown", "[email protected]"),
            new Person("Jacob", "Smith", "[email protected]"),
            new Person("Isabella", "Johnson", "[email protected]"),
            new Person("Ethan", "Williams", "[email protected]"),
            new Person("Emma", "Jones", "[email protected]"),
            new Person("Michael", "Brown", "[email protected]"),
            new Person("Jacob", "Smith", "[email protected]"),
            new Person("Isabella", "Johnson", "[email protected]"),
            new Person("Ethan", "Williams", "[email protected]"),
            new Person("Emma", "Jones", "[email protected]"),
            new Person("Michael", "Brown", "[email protected]"),
            new Person("Jacob", "Smith", "[email protected]"),
            new Person("Isabella", "Johnson", "[email protected]"),
            new Person("Ethan", "Williams", "[email protected]"),
            new Person("Emma", "Jones", "[email protected]"),
            new Person("Michael", "Brown", "[email protected]")
        );


    // REGULAR TABLE -------------------------------------------------------------------------
    Scene tableScene = new Scene(new Group());
    Stage tableStage = new Stage();
    tableStage.setTitle("Table View Sample");
    tableStage.setWidth(300);
    tableStage.setHeight(500);

    tableStage.show();
    regularTable.getItems().addAll(data);

    regularTable.setEditable(true);

    TableColumn regularFirstNameCol = new TableColumn("First Name");
    TableColumn regularLastNameCol = new TableColumn("Last Name");
    TableColumn regularEmailCol = new TableColumn("Email");

    regularFirstNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("firstName"));
    regularLastNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("lastName"));
    regularEmailCol.setCellValueFactory(new PropertyValueFactory<Person, String>("email"));

    regularTable.getColumns().addAll(regularFirstNameCol, regularLastNameCol, regularEmailCol);

    final VBox vbox1 = new VBox();
    vbox1.setSpacing(5);
    vbox1.setPadding(new Insets(10, 0, 0, 10));
    vbox1.getChildren().addAll(regularTable);

    ((Group) tableScene.getRoot()).getChildren().addAll(vbox1);

    tableStage.setScene(tableScene);

    // TREE TABLE ----------------------------------------------------------------------------------------------------------------------
    Scene scene = new Scene(new Group());
    stage.setTitle("Tree Table Sample");
    stage.setWidth(300);
    stage.setHeight(500);

    final Label label = new Label("Address Book");
    label.setFont(new Font("Arial", 20));

    treeTable.setEditable(true);

    TreeTableColumn firstNameCol = new TreeTableColumn("First Name");
    TreeTableColumn lastNameCol = new TreeTableColumn("Last Name");
    TreeTableColumn emailCol = new TreeTableColumn("Email");

    treeTable.getColumns().addAll(firstNameCol, lastNameCol, emailCol);

    final VBox vbox = new VBox();
    vbox.setSpacing(5);
    vbox.setPadding(new Insets(10, 0, 0, 10));
    vbox.getChildren().addAll(label, treeTable);

    ((Group) scene.getRoot()).getChildren().addAll(vbox);

    stage.setScene(scene);

    firstNameCol.setCellValueFactory(new TreeItemPropertyValueFactory<Person,String>("firstName"));
    lastNameCol.setCellValueFactory(new TreeItemPropertyValueFactory<Person,String>("lastName"));
    emailCol.setCellValueFactory(new TreeItemPropertyValueFactory<Person,String>("email"));

    TreeItem<Person> root = new TreeItem<Person>(new Person("TEST", "TEST", "TEST"));

    treeTable.setRoot(root);
    treeTable.setShowRoot(true);
    root.setExpanded(true);

    for (Person person : data){
        TreeItem<Person> p = new TreeItem<Person>(person);
        root.getChildren().add(p);
    }

    stage.show();


}

Кто-нибудь знает исправление/решение для этого, или это известная ошибка с TreeTableView?

РЕДАКТИРОВАТЬ: я только что попробовал это, используя этот пример

https://wikis.oracle.com/display/OpenJDK/TreeTableView+API+Examples

и я все еще получаю ту же проблему с отсутствующими / выбеленными строками.


person thatjavaguy09    schedule 28.08.2013    source источник
comment
Какую сборку jdk8 вы используете?   -  person Alexander Kirov    schedule 31.08.2013
comment
Я не совсем уверен, какую сборку я использую (есть ли способ проверить?). Я скачал ее 8/8/13, если это поможет.   -  person thatjavaguy09    schedule 03.09.2013
comment
java -version выведет что-то вроде 8.0-b###, я про ###...   -  person Alexander Kirov    schedule 04.09.2013
comment
б101. Должен ли я обновиться до более новой сборки?   -  person thatjavaguy09    schedule 04.09.2013
comment
Я скачал сборку 104, и это решило проблему. Огромное спасибо!   -  person thatjavaguy09    schedule 04.09.2013


Ответы (1)


Спасибо @Alexander Kirov за решение. Обновление до сборки 104 решило эту проблему.

person thatjavaguy09    schedule 04.09.2013
comment
В общем случае вы можете использовать javafx-jira для получения информации о существующих ошибках. (да, в javafx есть баги :) ) И вы тоже можете написать свой - person Alexander Kirov; 04.09.2013