title: ScrollPane containing ImageView does not update its scrollbars after calling setImage()
body: <p>I am experimenting JavaFX with a simple image viewer. I want it to display an image and, if it does not fit in the window, display scrollbars. The image to dislay is loaded with the <code>FileChooser</code> and set to the <code>ImageView</code> using <code>imageView.setImage(image)</code>.</p>
  
  <p>The problem is that the scrollbars of the containing <code>ScrollPane</code> <em>do not</em> update after calling <code>imageView.setImage(image)</code>. Instead, I need to perform an action that changes the scene (e.g. resize the window). It behaves the same when an image is displayed and another is loaded, i.e. the sizes of the scrollbars reflect the size of the previous image.</p>
  
  <hr>
  
  <p>The bug is reproducible using the following cut-down version of the code:</p>
  
  <p>(Java)</p>
  
  <pre><code>import java.io.File;
  import java.io.FileInputStream;
  import java.io.IOException;
  import java.io.InputStream;
  
  import javafx.application.Application;
  import javafx.fxml.FXML;
  import javafx.fxml.FXMLLoader;
  import javafx.scene.Scene;
  import javafx.scene.image.Image;
  import javafx.scene.image.ImageView;
  import javafx.scene.layout.BorderPane;
  import javafx.stage.FileChooser;
  import javafx.stage.Stage;
  
  public class ImageViewerBug extends Application
  {
      @FXML private ImageView imageView;
  
      @Override
      public void start(Stage primaryStage) throws Exception {
          FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("ImageViewerBug.fxml"));
          fxmlLoader.setController(this);
          try {
              BorderPane borderPane = (BorderPane) fxmlLoader.load();
              Scene scene = new Scene(borderPane);
              primaryStage.setScene(scene);
              primaryStage.show();
          }
          catch( IOException e ) {
              throw new RuntimeException(e);
          }
      }
  
      public void loadClicked() {
          FileChooser fileChooser = new FileChooser();
          File f = fileChooser.showOpenDialog(null);
          if( f != null ) {
              try( InputStream is = new FileInputStream(f) ) {
                  Image image = new Image(is);
                  imageView.setImage(image);
              }
              catch( IOException e ) {
                  e.printStackTrace();
              }
          }
      }
  
      public static void main(String[] args) {
          launch(args);
      }
  }
  </code></pre>
  
  <p>(FXML)</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;?import java.lang.*?&gt;
  &lt;?import java.util.*?&gt;
  &lt;?import javafx.scene.*?&gt;
  &lt;?import javafx.scene.Group?&gt;
  &lt;?import javafx.scene.control.*?&gt;
  &lt;?import javafx.scene.image.*?&gt;
  &lt;?import javafx.scene.layout.*?&gt;
  &lt;?import javafx.scene.paint.*?&gt;
  
  &lt;BorderPane id="BorderPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml"&gt;
    &lt;center&gt;
      &lt;ScrollPane prefHeight="200.0" prefWidth="200.0"&gt;
        &lt;content&gt;
          &lt;Group&gt;
            &lt;ImageView fx:id="imageView" pickOnBounds="true" preserveRatio="true" /&gt;
          &lt;/Group&gt;
        &lt;/content&gt;
      &lt;/ScrollPane&gt;
    &lt;/center&gt;
    &lt;top&gt;
      &lt;ToolBar&gt;
        &lt;items&gt;
          &lt;Button mnemonicParsing="false" onAction="#loadClicked" text="Load" /&gt;
        &lt;/items&gt;
      &lt;/ToolBar&gt;
    &lt;/top&gt;
  &lt;/BorderPane&gt;
  </code></pre>