JavaFX: Disable horizontal scrollbar of TableView


I have the following question: I would like to disable the horizontal scrollbar of my TableView. It may not be visible, but also the TableView may not be scrolled horizontally either. The visibility of the horizontal scrollbar can be set in the CSS:

.table-view *.scroll-bar:horizontal *.increment-button,
.table-view *.scroll-bar:horizontal *.decrement-button {
    -fx-background-color: null;
    -fx-background-radius: 0;
    -fx-background-insets: 0;
    -fx-padding: 0;

.table-view *.scroll-bar:horizontal *.increment-arrow, 
.table-view *.scroll-bar:horizontal *.decrement-arrow {
    -fx-background-color: null;
    -fx-background-radius: 0;
    -fx-background-insets: 0;
    -fx-padding: 0;
    -fx-shape: null;

Sources: How to hide the horizontal Scrollbar of a ListView in JavaFX and

This works fine, but I can still scroll the TableView horizontally (although the scrollbar is not visible). I have set the column widths as follows:


This works when the TableView does not show any rows. But when I populate it (by pressing a button), the columns are slightly stretched and this enables the TableView to be scrolled horizontally.

Is it only possible to hide the scrollbar, or can you also disable the scrolling itself?

Any help is greatly appreciated!

5/23/2017 11:47:28 AM

Try to set


without setting pref width of columns.

11/3/2014 4:53:12 PM

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