【发布时间】:2022-09-29 02:10:37
【问题描述】:
我有一个由代码创建的屏幕,在那个屏幕中,我将在 N... 按钮处添加 1,但他们喜欢按钮在屏幕上自我组织,占用所有屏幕空间。但是当添加按钮时,它们被添加到一个队列中。
Stage primaryStage = (Stage) btActivity1.getScene().getWindow();
Stage stageLayout = new Stage();
stageLayout.setHeight(primaryStage.getHeight());
stageLayout.setWidth(primaryStage.getWidth());
stageLayout.setMaximized(false);
stageLayout.setTitle(\"Layout: \" + cbListOfRouter.getValue().getSerie());
stageLayout.initOwner(primaryStage);
stageLayout.initModality(Modality.APPLICATION_MODAL);
HBox box = new HBox();
box.setStyle(\"-fx-background-color: gainsboro; -fx-border-color: gainsboro; -fx-background-radius: 10; -fx-border-radius: 10\");
box.setPadding(new Insets(10, 20, 10, 20));
box.setSpacing(5);
box.setAlignment(Pos.BASELINE_LEFT);
box.getChildren().addAll(createButtonsLayout());
box.getChildren().add(new Button());
Vector<Button> listWoButtons = createButtonsLayout();
int count = 1;
for (Button bt : listWoButtons) {
box.getChildren().add(bt);
count++;
}
stageLayout.setScene(new Scene(box));
stageLayout.showAndWait();
-
使用
FlowPane而不是HBox -
谢谢詹姆斯,效果很好
标签: javafx