JavaFx 2.1, 2.2 TableView update issue

后端 未结 7 1009
青春惊慌失措
青春惊慌失措 2021-02-06 17:41

My application uses JPA read data into TableView then modify and display them. The table refreshed modified record under JavaFx 2.0.3. Under JavaFx 2.1, 2.2, the table wouldn\'t

7条回答
  •  星月不相逢
    2021-02-06 18:39

    I had the same problem and after some search this is my workaround. I found that if the columns are removed and then re-added the table is updated.

    public static  void refreshTableView(final TableView tableView, final List> columns, final List rows) {
        if (tableView == null) {
            throw new NullPointerException();
        }
        if (columns == null) {
            throw new NullPointerException();
        }
        if (rows == null) {
            throw new NullPointerException();
        }
    
        tableView.getColumns().clear();
        tableView.getColumns().addAll(columns);
    
        ObservableList list = FXCollections.observableArrayList(rows);
        tableView.setItems(list);
    }
    


    Example of usage:

    refreshTableView(myTableView, Arrays.asList(col1, col2, col3), rows);
    

提交回复
热议问题