I coudn't find in internet the right answer, how can I populate tableviw with ObservableMap as MapProperty. I would like to show the articles in a tableview sorted by value.
public class Article {
private MapProperty<String, Integer> article = new SimpleMapProperty<>();
public final ObservableMap<String, Integer> geArticle() {
return article.get();
}
public final void setArticle(ObservableMap<String, Integer> value) {
article.set(value);
}
public MapProperty<String, Integer> articleProperty() {
return article;
}
}
public class TableController extends VBox implements Initializable{
@FXML private TableView<Article> tableView;
@FXML private TableColumn<Article, String> article;
@FXML private TableColumn<Article, Integer> count;
......
@Override
public void initialize(URL location, ResourceBundle resources) {
article.setCellValueFactory(new PropertyValueFactory<Article, String>("article"));
count.setCellValueFactory(new PropertyValueFactory<Article, Integer>("count"));
}
}