How do you get JavaFX ListView to be the height of its items?

I just found out that Paul Marshall’s answer can be reducted to a one-liner using Bindings.size that creates a numeric jfx property representing the size of an ObservableList :

listView.prefHeightProperty().bind(Bindings.size(itemListProperty).multiply(LIST_CELL_HEIGHT));

The list cell height must sadly still be hardcoded AFAIK.

Leave a Comment