Answer the question
In order to leave comments, you need to log in
How to add data from collection to TableView?
There is one column to which ordinary string elements must be passed through the collection.
@FXML
TableView TableView;
@FXML
TableColumn Result;
@FXML
private void StartSearch(ActionEvent event) {
ObservableList<SimpleStringProperty> data = FXCollections.observableArrayList();
data.add(new SimpleStringProperty("Florida"));
data.add(new SimpleStringProperty("NY"));
data.add(new SimpleStringProperty("NJ"));
TableView.setItems(data);
Result.setCellValueFactory(new PropertyValueFactory("result"));
TableView.getColumns().setAll(Result);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question