I want to populate TableView
with
String, String
I have only two columns. I couldn't do it.
What I tried so far is:
ObservableList<String> data = FXCollections.observableArrayList();
for (blabla){
data.addAll(Id,Name);
}
tableView.getItems().addAll(data);
and nothing shows on table. But when I do tableView.getItems()
and print it, I see the data I've added. But on table, nothing is shown.
I create my columns as follows:
TableColumn idColumn = new TableColumn("Id");
TableColumn nameColumn = new TableColumn("Name");
I see some examples on the internet in which an object is created to populate the TableView
but I don't want to create a class just for a table view. Is there any other possible ways to accomplish this?
Edit:
I just want to have something like:
ObservableList<String,String> data = FXCollections.observableArrayList();
for(int i = 1; i<blabla i++){
data.add((i)+"S",myList.get(i));
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…