title: JavaFX: Disable horizontal scrollbar of TableView
body: <p>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:</p>
  
  <pre><code>.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;
  }
  </code></pre>
  
  <p><strong>Sources:</strong> <a href="https://stackoverflow.com/questions/12670137/how-to-hide-the-horizontal-scrollbar-of-a-listview-in-javafx">How to hide the horizontal Scrollbar of a ListView in JavaFX</a> and <a href="https://community.oracle.com/thread/2377826?tstart=0" rel="noreferrer">https://community.oracle.com/thread/2377826?tstart=0</a>.</p>
  
  <p>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:</p>
  
  <pre><code>col1.setPrefWidth(table.getPrefWidth()*0.40);
  col2.setPrefWidth(table.getPrefWidth()*0.20);
  col3.setPrefWidth(table.getPrefWidth()*0.20);
  </code></pre>
  
  <p>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.</p>
  
  <p>Is it only possible to hide the scrollbar, or can you also disable the scrolling itself?</p>
  
  <p>Any help is greatly appreciated!</p>