[英]How to populate TableView which in it i can have radiobutton in javafx
[英]How can I populate a TableView in JavaFX by using Arraylist?
我想通過使用數組列表來填充javafx中的表視圖。我不想使用任何模型。我想將數組列表作為填充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
您必須使用ObservableList
作為數據源,並在擁有可以使用的List
時實現此目的:
FXCollections.observableList(yourList);
如果沒有模型,那么您只想顯示一個列列表。 因此,在假設您的arraylist的對象類型是包含類(原始數據類型)(如Integer,Double,String等)之后,您可以使用ListView而不是TableView。
List<Double> doubles = new ArrayList<Double>();
doubles.add(12.12d);
ObservableList<Double> names = FXCollections.observableArrayList(doubles);
ListView<Double> listView = new ListView<Double>(names);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.