How to hide the horizontal Scrollbar of a ListView in JavaFX


Question

How can I hide the horizontal scrollbar of a ListView? I tried it in different ways and probably it's totally easy, but I just can't get it to run.

1
9
8/4/2018 12:51:43 PM

Accepted Answer

Try this in the CSS:

.list-view .scroll-bar:horizontal .increment-arrow,
.list-view .scroll-bar:horizontal .decrement-arrow,
.list-view .scroll-bar:horizontal .increment-button,
.list-view .scroll-bar:horizontal .decrement-button {
    -fx-padding:0;
}
33
5/4/2013 7:05:07 PM

I think that would be nicer a ListCell with a Pane(for example StackPane) and a Label inside that will have the ellipsis functionality:

StackPane pane = new StackPane();
pane.setStyle("-fx-border-color:red;");
pane.setMinWidth(0);
pane.setPrefWidth(1);
pane.getChildren().add(label);

You can have a look at this link.

The same solution could be used for other ListCells complex.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon