title: How to center the content of a javafx 8 scrollpane
body: <p>I have a ScrollPane, which contains a GridPane, which contains an ImageView, which contains an Image.  What I want is for the Image to be centered in the GridPane.</p>
  
  <p>Without the ScrollPane I was able to accomplish this with setAlignment(Pos.TOP_CENTER), however once I added the GridPane to the ScrollPane the Image was displayed in the upper-left corner.</p>
  
  <p>How do I either get the ScrollPane to use the setAlignment() value or manually center the Image?</p>
  
  <p>---example edit---</p>
  
  <p>code without scrollpane:</p>
  
  <pre><code>public class ImageDB extends Application
  {
    @Override
    public void start(Stage root)
    {
      Image image = new Image("0.jpg");
      ImageView view = new ImageView();
      view.setImage(image);
  
      GridPane grid = new GridPane();
      grid.getChildren().add(view);
  
      grid.setAlignment(Pos.TOP_CENTER);
  
      BorderPane border = new BorderPane();
      border.setCenter(grid);
  
      root.setScene(new Scene(border));
      root.setMaximized(true);
      root.show();
    }
  }
  </code></pre>
  
  <p>result:
  <a href="https://i.imgur.com/eWvBQy6.png" rel="noreferrer">https://i.imgur.com/eWvBQy6.png</a></p>
  
  <p>code with scrollpane:</p>
  
  <pre><code>public class ImageDB extends Application
  {
    @Override
    public void start(Stage root)
    {
      Image image = new Image("0.jpg");
      ImageView view = new ImageView();
      view.setImage(image);
  
      ScrollPane scroll = new ScrollPane();
      scroll.setContent(view);
  
      GridPane grid = new GridPane();
      grid.getChildren().add(scroll);
  
      grid.setAlignment(Pos.TOP_CENTER);
  
      BorderPane border = new BorderPane();
      border.setCenter(scroll);
  
      root.setScene(new Scene(border));
      root.setMaximized(true);
      root.show();
    }
  }
  </code></pre>
  
  <p>result:
  <a href="https://i.imgur.com/1aJDX4m.png" rel="noreferrer">https://i.imgur.com/1aJDX4m.png</a></p>