title: JavaFX Anchor Constraints
body: <p>I have an FXML file which has a split pane and 2 rectangles in it.  I have both rectangles anchored properly via the FXML but from the code I am generating new rectangles but I can't seem to get the constraints on them working, I set them to the same settings as the rectangles in the FXML(constraint wise) but nothing.  I think the issue is the rectangles in the FXML are inside a Split Pane where as the ones generated from the Java code are in the Main AnchorPane.  Here is the code any ideas?</p>
  
  <pre><code>public void start(Stage stage) throws Exception {
      //GridPane root = new GridPane();
      AnchorPane root = fxmlLoader.load(getClass().getClassLoader().getResource("fxml/TestConveyorView.fxml")).getRoot();
      Box box = new Box(1);
      Rectangle rect = new Rectangle(50,50, box.getStatus().getColor());
      rect.setX(385.0);
      AnchorPane.setLeftAnchor(rect, 385.0);
      AnchorPane.setRightAnchor(rect, 294.0);
      root.getChildren().addAll(rect);
      Scene scene = new Scene(root);
  
      // BackgroundImage background = new BackgroundImage(null, BackgroundRepeat.REPEAT, BackgroundRepeat.REPEAT, BackgroundPosition.DEFAULT, BackgroundSize.DEFAULT);
      stage.setScene(scene);
      stage.show();
  }
  </code></pre>