title: Auto resize ScrollPane
body: <p>I want to resize ScrollPane to fit the parent component. I tested this code:</p>
  
  <pre><code>import javafx.application.Application;
  import static javafx.application.Application.launch;
  import javafx.scene.Scene;
  import javafx.scene.control.ScrollPane;
  import javafx.scene.control.ScrollPane.ScrollBarPolicy;
  import javafx.scene.layout.BorderPane;
  import javafx.scene.layout.VBox;
  import javafx.stage.Stage;
  
  
  public class MainApp extends Application {
  
      @Override
      public void start(Stage stage) throws Exception {
  
          BorderPane bp = new BorderPane();
          bp.setPrefSize(600, 600);
          bp.setMaxSize(600, 600);
          bp.setStyle("-fx-background-color: #2f4f4f;");
  
          VBox vb = new VBox(bp);
  
          ScrollPane scrollPane = new ScrollPane(vb);
          scrollPane.setFitToHeight(true);
          scrollPane.setFitToWidth(true);
  
          scrollPane.setHbarPolicy(ScrollBarPolicy.AS_NEEDED);
          scrollPane.setVbarPolicy(ScrollBarPolicy.AS_NEEDED);
  
          Scene scene = new Scene(scrollPane);
  
          stage.setScene(scene);
          stage.show();
      }
  
      public static void main(String[] args) {
          launch(args);
      }
  }
  </code></pre>
  
  <p>But as you can see I don't see tree scroll bars. Is there anything wrong into my code?</p>
  
  <p><img src="https://i.stack.imgur.com/TlWAT.png" alt="enter image description here"></p>