title: JavaFx ImageView won't resize on fitWidthProperty bind to VBox
body: <p>I am trying to re-size an image so it fits (scaled) in the space allotted by a <code>SplitPane</code> (for workaround suggestions: this image will change when running the program, it should be generated from the text). The ImageView I'm using currently changes the location of the <code>SplitPane</code> <code>Divider</code>. The divider can never cause the <code>ImageView</code> to decrease past the size of the image.</p>
  
  <p><a href="http://imgur.com/a/lsttE" rel="nofollow">Two images showing this behavior</a>.</p>
  
  <p>Linking the <code>ImageView</code> fitWidthProperty to a <code>VBox</code> has not given me the resize behavior I expected. Increasing the <code>ImageView</code>'s size does work (where it is fixed without the binding), but the image never grows, it just gets borders around it.</p>
  
  <p>My MWE:</p>
  
  <p><code>sample.fxml</code>:</p>
  
  <pre><code>&lt;?import javafx.scene.control.SplitPane?&gt;
  &lt;?import javafx.scene.control.TextArea?&gt;
  &lt;?import javafx.scene.image.ImageView?&gt;
  &lt;?import javafx.scene.layout.HBox?&gt;
  &lt;?import javafx.scene.layout.VBox?&gt;
  &lt;SplitPane orientation="HORIZONTAL" xmlns:fx="http://javafx.com/fxml"&gt;
      &lt;TextArea fx:id="textArea"/&gt;
      &lt;VBox fx:id="vBox" alignment="CENTER"&gt;
          &lt;HBox fx:id="hBox" alignment="CENTER"&gt;
              &lt;ImageView fx:id="imageView"/&gt;
          &lt;/HBox&gt;
      &lt;/VBox&gt;
  &lt;/SplitPane&gt;
  </code></pre>
  
  <p><code>Controller.java</code>:</p>
  
  <pre><code>import javafx.fxml.FXML;
  import javafx.scene.control.TextArea;
  import javafx.scene.image.Image;
  import javafx.scene.image.ImageView;
  import javafx.scene.layout.HBox;
  import javafx.scene.layout.VBox;
  
  public class Controller {
      @FXML
      private TextArea textArea = new TextArea();
      @FXML
      private VBox vBox = new VBox();
      @FXML
      private HBox hBox = new HBox();
      @FXML
      private ImageView imageView = new ImageView();
  
      public Controller() {
          imageView.fitWidthProperty().bind(vBox.widthProperty());
          imageView.fitHeightProperty().bind(hBox.heightProperty());
      }
  
      public void start() {
          textArea.setText("text");
  
          Image image = new Image("https://www.google.nl/images/srpr/logo11w.png");
          imageView.setImage(image);
      }
  }
  </code></pre>
  
  <p>and <code>Main.java</code>:</p>
  
  <pre><code>import javafx.application.Application;
  import javafx.fxml.FXMLLoader;
  import javafx.scene.Parent;
  import javafx.scene.Scene;
  import javafx.stage.Stage;
  
  public class Main extends Application {
  
      @Override
      public void start(final Stage primaryStage) throws Exception {
          final Controller controller = new Controller();
  
          FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("sample.fxml"));
          fxmlLoader.setController(controller);
  
          final Parent root = fxmlLoader.load();
          primaryStage.setTitle("MWE");
          final Scene scene = new Scene(root, 640, 480);
          primaryStage.setScene(scene);
          primaryStage.show();
  
          controller.start();
      }
  
      public static void main(String[] args) {
          launch(args);
      }
  }
  </code></pre>