title: Unable to resize correctly nested Pane JavaFX
body: <p>I've the current situation: a main windows with a main <code>BorderPane</code>. At the center of it I have an <code>AnchorPane</code> with some objects inside. I want to distribute the objects equally inside the height of the pane, even if the pane is resized.</p>
  
  <p>The problem I'm falled in is that all things works when the resize increase the height of the pane. When I decrease the size of the window, the pane's height continue to increase.</p>
  
  <p>I have reproduced the error in this example application using a simple line (in my application I've also a line like this):</p>
  
  <pre><code>import javafx.application.Application;
  
  import javafx.scene.Scene;
  import javafx.scene.layout.AnchorPane;
  import javafx.scene.layout.BorderPane;
  import javafx.scene.layout.Pane;
  import javafx.scene.shape.Line;
  import javafx.stage.Stage;
  
  public class ResizeProblem extends Application {
  
      @Override
      public void start(Stage primaryStage) {
          BorderPane root = new BorderPane();
          AnchorPane inner = new AnchorPane();
  
          Line line = new Line();
  
          // comment from here...
          root.setCenter(inner);
          Pane pane = inner;
          // ...to here and uncomment next to make things work
          //Pane pane = root;
  
          line.startXProperty().bind(pane.widthProperty().divide(2));
          line.endXProperty().bind(pane.widthProperty().divide(2));
          line.setStartY(0.);
          line.endYProperty().bind(pane.heightProperty());
  
          pane.heightProperty().addListener((obs, ov, nv) -&gt; System.out.println("ov: " + ov + " nv: " + nv));
  
          pane.getChildren().add(line);
  
          Scene scene = new Scene(root, 300, 250);
  
          primaryStage.setTitle("Resize Problem");
          primaryStage.setScene(scene);
          primaryStage.show();
      }
  
      public static void main(String[] args) {
          launch(args);
      }
  
  }
  </code></pre>
  
  <p>I've seen that avoiding nesting, everything works as expected.</p>
  
  <p>What's wrong with that?</p>
  
  <p>Please help me find the right direction.</p>