2013-08-28 57 views
4

,當我已經與TreeTableView在​​已經試驗了。在我的程序啓動並運行之後,我注意到一個問題,即當我滾動時,行會被截斷。我嘗試了一切,從重置單元格的可見性,更新時間,希望在更新時重繪,甚至重置列的可見性。這是我寫的一個測試小程序,用於顯示當您滾動查看樹表視圖時,行會變空,但對於表視圖,情況並非如此。JavaFX的TreeTableView行滾動

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(); 


} 

有誰知道這個修復/解決方案,或這是一個已知的bug與TreeTableView

編輯:我只是想用這個這個例子

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

,我仍然得到行丟失/被粉飾出的同樣的問題。

+2

哪個構建jdk8的你呢? –

+0

我不太確定哪個構建我使用(有沒有辦法檢查?)我下載了它13年8月8日是否有幫助。 – thatjavaguy09

+1

java -version會輸出類似於8.0-b ###的東西,我是關於### ... –

回答

1

感謝@Alexander基洛夫的解決方案。升級到構建104解決了這個問題。

+1

在一般情況下,您可以使用javafx-jira獲取有關現有錯誤的信息。 (是的,在javafx中有錯誤:))你也可以提交你的文件 –