title: Javafx TableView in a ScrollPane
body: <p>I'm having some issues with the Constrained Resize Policy for a TableView inside a ScrollPane.
  It seems as though the headings do not line up completely with its column. On scroll or resize the columns snap to their correct position.</p>
  
  <p>I created a small example to demonstrate:</p>
  
  <pre><code>import java.util.ArrayList;
  
  import javafx.application.Application;
  import javafx.beans.property.SimpleStringProperty;
  import javafx.beans.property.StringProperty;
  import javafx.collections.FXCollections;
  import javafx.scene.Scene;
  import javafx.scene.control.ScrollPane;
  import javafx.scene.control.TableColumn;
  import javafx.scene.control.TableView;
  import javafx.scene.control.cell.PropertyValueFactory;
  import javafx.scene.layout.VBox;
  import javafx.stage.Stage;
  
  public class Test extends Application
  {
      public static void main(String[] args) throws Exception
      {
          launch(args);
      }
  
      @Override
      public void start(Stage primarystage) throws Exception
      {
          // Create layout
          VBox root = new VBox();
  
          TableView&lt;TableObject&gt; table = new TableView&lt;TableObject&gt;();
          TableColumn&lt;TableObject, String&gt; col1 = new TableColumn&lt;TableObject, String&gt;("Column 1");
          TableColumn&lt;TableObject, String&gt; col2 = new TableColumn&lt;TableObject, String&gt;("Column 2");
          table.getColumns().addAll(col1, col2);
  
          col1.setCellValueFactory(new PropertyValueFactory&lt;TableObject, String&gt;("column1"));
          col2.setCellValueFactory(new PropertyValueFactory&lt;TableObject, String&gt;("column2"));
          table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
  
          root.getChildren().add(table);
  
          ScrollPane scrollpane = new ScrollPane();
          scrollpane.setFitToWidth(true);
          scrollpane.setFitToHeight(true);
          scrollpane.setPrefSize(500, 200);
          scrollpane.setContent(root);
  
          // Create and show scene            
          Scene scene = new Scene(scrollpane);
          primarystage.setScene(scene);
          primarystage.show();
  
          // Populate table
          ArrayList&lt;TableObject&gt; data = new ArrayList&lt;TableObject&gt;();
          for (int i = 0; i &lt; 20;)
          {
              TableObject entry = new TableObject(String.valueOf(i++), String.valueOf(i++));
              data.add(entry);
          }
  
          table.setItems(FXCollections.observableArrayList(data));
      }
  
      public class TableObject
      {
          private StringProperty column1;
          private StringProperty column2;
  
          public TableObject(String col1, String col2)
          {
              column1 = new SimpleStringProperty(col1);
              column2 = new SimpleStringProperty(col2);
          }
  
          public StringProperty column1Property()
          {
              return column1;
          }
  
          public StringProperty column2Property()
          {
              return column2;
          }
      }
  }
  </code></pre>
  
  <p>The result is this:</p>
  
  <p><img src="https://i.stack.imgur.com/ykCxb.jpg" alt="Sample Screenshot"></p>
  
  <p>Is there perhaps something I am missing here?</p>
  
  <p>Thanks</p>