I’m trying to add rows which I selected in one table to another table. I’m not sure how to dynamically append rows. The code I did so far just changes the first row.
int hr = 1;
if ( hr == 1){
ObservableList<TableColumn<ObservableList<StringProperty>, ?>> header = tableId.getColumns();
auswTable.getColumns().addAll(header);
hr = 2;
}
ObservableList<ObservableList<StringProperty>> content =
tableId.getSelectionModel().getSelectedItems();
auswTable.setItems(content);
This was happening because In your code for table2, you set selectedItems observable list as setItems ,so when ever user selected a row/rows in table 1 ,it will automatically added table2. To fix this issue define a new ObserbaleList for table2 and add values from selecteditems to it.
Sample Code :