我想调整ScrollPane,因为它适合其父容器。我测试了这个代码:使ScrollPane适合其父在javafx
@Override
public void start(Stage stage) throws Exception {
VBox vb = new VBox();
vb.setPrefSize(600, 600);
vb.setMaxSize(600, 600);
ScrollPane scrollPane = new ScrollPane();
scrollPane.setFitToHeight(false);
scrollPane.setFitToWidth(false);
scrollPane.setHbarPolicy(ScrollBarPolicy.AS_NEEDED);
scrollPane.setVbarPolicy(ScrollBarPolicy.AS_NEEDED);
VBox vb2 = new VBox();
vb.getChildren().add(scrollPane);
scrollPane.getChildren().add(vb2);
Scene scene = new Scene(vb);
stage.setScene(scene);
stage.show();
}
现在我想让scrollPane的宽度,高度与外VBox(vb)相同。但我失败了!有人可以帮我吗?