Reputation: 2277
I want to populate table view in javafx by using array list .I do not want to use any model .i want to make array list as my source of data for populating tableview .
Code:
List<Double> doubles = new ArrayList<Double>();
doubles.add(12.12d);
ObservableList<Double> names = FXCollections.observableArrayList(doubles);
TableView table_view = new TableView<>(names);
firstDataColumn.setCellFactory(?????);/// here the problem comes what is the cell factory in case of arraylist
Upvotes: 2
Views: 12847
Reputation: 49185
If there is no model then you want to show only one column list. So after taking assumption of that your arraylist's object type is the wrapper class (of the primitive data types) like Integer, Double, String etc., you can use ListView instead of TableView.
List<Double> doubles = new ArrayList<Double>();
doubles.add(12.12d);
ObservableList<Double> names = FXCollections.observableArrayList(doubles);
ListView<Double> listView = new ListView<Double>(names);
Upvotes: 1
Reputation: 1630
You must use a ObservableList
as your datasource and to achieve this when you have a List
you can use:
FXCollections.observableList(yourList);
Upvotes: 2