是否可以使BorderPane的右侧具有窗口高度和底部/顶部边缘,然后以右侧的开头结束?
答案 0 :(得分:2)
AFAIK无法做到这一点,但您可以使用GridPane
private static void setBackground(Region region, Color color) {
region.setBackground(new Background(new BackgroundFill(color, CornerRadii.EMPTY, Insets.EMPTY)));
}
@Override
public void start(Stage primaryStage) {
GridPane gridPane = new GridPane();
RowConstraints rConstranits1 = new RowConstraints();
rConstranits1.setVgrow(Priority.NEVER);
RowConstraints rConstranits2 = new RowConstraints();
rConstranits2.setVgrow(Priority.ALWAYS);
RowConstraints rConstranits3 = new RowConstraints();
rConstranits3.setVgrow(Priority.NEVER);
ColumnConstraints cConstraints1 = new ColumnConstraints();
cConstraints1.setHgrow(Priority.NEVER);
ColumnConstraints cConstraints2 = new ColumnConstraints();
cConstraints2.setHgrow(Priority.ALWAYS);
ColumnConstraints cConstraints3 = new ColumnConstraints();
cConstraints3.setHgrow(Priority.NEVER);
gridPane.getColumnConstraints().addAll(cConstraints1, cConstraints2, cConstraints3);
gridPane.getRowConstraints().addAll(rConstranits1, rConstranits2, rConstranits3);
Region top = new Region();
top.setPrefSize(300, 100);
setBackground(top, Color.RED);
Region bottom = new Region();
bottom.setPrefSize(400, 50);
setBackground(bottom, Color.YELLOW);
Region center = new Region();
setBackground(center, Color.BLUE);
Region right = new Region();
setBackground(right, Color.LIME);
right.setPrefSize(200, 500);
Region left = new Region();
setBackground(left, Color.BROWN);
left.setPrefSize(200, 400);
gridPane.add(right, 2, 0, 1, 3);
cConstraints3.maxWidthProperty().bind(right.prefWidthProperty());
cConstraints3.minWidthProperty().bind(right.prefWidthProperty());
gridPane.add(top, 0, 0, 2, 1);
rConstranits1.minHeightProperty().bind(top.prefHeightProperty());
rConstranits1.maxHeightProperty().bind(top.prefHeightProperty());
gridPane.add(bottom, 0, 2, 2, 1);
rConstranits3.minHeightProperty().bind(bottom.prefHeightProperty());
rConstranits3.maxHeightProperty().bind(bottom.prefHeightProperty());
gridPane.add(center, 1, 1);
gridPane.add(left, 0, 1);
cConstraints1.minWidthProperty().bind(left.prefWidthProperty());
cConstraints1.maxWidthProperty().bind(left.prefWidthProperty());
Scene scene = new Scene(gridPane);
primaryStage.setScene(scene);
primaryStage.show();
}
答案 1 :(得分:1)
嵌套两个BorderPanes是另一种选择,然后依赖于BorderPane的内置高度和放大器。宽度管理。感谢fabian的示例基础和setBackground例程!
021 no connection named "-c"
021 no connection named "-c"
021 no connection named "-c"
021 no connection named "-c"