I'm testing myself with a simple CSV Viewer using JavaFX and I'm stuck at populating the table data. I do create the columns dynamically, but the data values are a no-go. I searched the web and found a few ways but all ways include a ObservableList with a custom class (including get/set), which in a CSV Viewer must be dynamically (The CSV can have any number of columns, and that means any number of data values).
Example:
List<String> columns;
List<List<String>> data;
/* Fills 'columns' and 'data' */
parseCSV("C:/list.csv");
int columnIndex = 0;
TableColumn [] tableColumns = new TableColumn[columns.size()];
for(String columName : columns) {
tableColumns[columnIndex++] = new TableColumn(columName);
}
table1.getColumns().addAll(tableColumns);
for(List<String> dataList : data) {
table1.setItems(dataList); // Requires an ObservableList!
}