0
我放在一個HBox
爲BorderPane
中心的中心填滿可用空間,這是對我的一個Dialog
的DialogPane
唯一直接Node
通過使用此代碼:HBox中不borderpane
public GameDialog(Player[] players) {
setTitle("Spiel eintragen");
setWidth(WIDTH);
setHeight(HEIGHT);
createLeftBox();
createRightBox(players);
// Center
this.center = new HBox(leftBox, rightBox);
center.setStyle("-fx-border-color: #00ff00;");
center.getChildren()
.forEach(b -> HBox.setMargin(b, INSETS));
// Bottom
this.btnOk = new Button("ok");
this.btnCancel = new Button("abbrechen");
this.bottom = new HBox(btnOk, btnCancel);
bottom.getChildren()
.forEach(b -> HBox.setMargin(b, INSETS));
// Pane
this.pane = new BorderPane(center);
pane.setBottom(bottom);
pane.setPrefSize(WIDTH, HEIGHT);
getDialogPane().setPrefSize(WIDTH, HEIGHT);
getDialogPane().getChildren().add(pane);
...
}
private void createLeftBox() {
// Points spinner
List<Integer> points = Stream.iterate(0, Util::increment)
.limit(MAX_POINTS)
.collect(Collectors.toList());
this.spPoints = new Spinner<>(observableArrayList(points));
// Solo combobox
List<Solotype> soli = Arrays.asList(Solotype.values());
this.cbSolo = new ComboBox<>(observableArrayList(soli));
cbSolo.setOnAction(e -> changed());
// Bock checkbox
this.chBock = new CheckBox("Bock");
// Left box
leftBox = new VBox(spPoints, cbSolo, chBock);
leftBox.getChildren()
.forEach(n -> VBox.setMargin(n, INSETS));
leftBox.setStyle("-fx-border-color: #ff0000");
}
private void createRightBox(Player[] players) {
List<Player> playerlist = Arrays.asList(players);
// Right box
rightBox = new VBox();
List<Node> rightChildren = rightBox.getChildren();
this.playerBoxes = playerlist.stream()
.collect(toMap(p -> p,
p -> new HBox(4)));
this.players = playerlist.stream()
.collect(toMap(p -> p,
this::createToggleGroup));
playerBoxes.values()
.stream()
.peek(rightChildren::add)
.forEach(b -> VBox.setMargin(b, INSETS));
rightBox.setStyle("-fx-border-color: #ff0000");
}
我的課GameDialog
擴展了javafx-class Dialog<R>
。但BorderPane
中心的HBox
未填滿所有可用空間。它只是看起來是這樣的:
我試圖setMinWidth,setMinHeight,setPrefSize,setFillWidth(真)和setFillHeight(真)在幾個H-和縱向方框的。沒有改變。我只是不明白這種行爲。有任何想法嗎?
我假設'BorderPane'沒有你想象的那麼大。將一個可見的邊框放置到窗格中以將其可視化 – Dici
我向其添加了一個邊框: pane.setStyle(「 - fx-border-color:#0000ff;」 +「-fx-border-width:4px;」 ); 但這沒有奏效。我沒有看到任何額外的邊框。 也許你是對的,它不是VBox小,而是BorderPane。在這種情況下,我仍然有同樣的問題:爲什麼BorderPane不能填滿所有可用空間? – David
您不顯示與邊框窗格相關的代碼,因此很難知道 – Dici