我在Gui的BorderPane中心有一个SplitPane(垂直)。在我的SplitPane中,将HBox添加为顶部,将FlowPane添加为底部。每次我将一组卡添加到VBox并将VBox添加到FlowPane时,它都会一个接一个地添加VBox,而不是垂直添加。有人知道为什么吗?
RewriteRule ^([_A-Z0-9a-z-+]+)$ profile.php?user=$1 [S=1]
我的GameView.fxml,其中我将SplitPane添加为BorderPane的中心。
@FXML
private FlowPane setsArea;
//sets
public void addSet(CardSet set) {
VBox setView = new VBox(20);
for (Card card : set.getCards()) {
ImageView imageView = new ImageView(card.getImgUrl());
setView.getChildren().add(imageView);
}
setsArea.getChildren().add(setView);
setViews.put(set, setView);
}
我如何添加卡集:
<center>
<SplitPane dividerPositions="0.5" orientation="VERTICAL" prefHeight="200.0" prefWidth="160.0" style="-fx-background-image: url('game.jpg');" BorderPane.alignment="CENTER">
<items>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0">
<children>
<HBox fx:id="playAreaTop" />
</children></AnchorPane>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0">
<children>
<FlowPane fx:id="setsArea" />
</children></AnchorPane>
</items>
</SplitPane>
</center>
谢谢。
答案 0 :(得分:0)
将图像添加到VBox中并将它们全部放入FlowPane中时,不要使它们垂直堆叠,您应该将FlowPane替换到VBox中,然后将ImageViews添加到VBox中,以便将其垂直堆叠,如下所示:
<SplitPane dividerPositions="0.5" orientation="VERTICAL" prefHeight="200.0" prefWidth="160.0" style="-fx-background-image: url('game.jpg');" BorderPane.alignment="CENTER">
<items>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0">
<children>
<HBox fx:id="playAreaTop" />
</children></AnchorPane>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0">
<children>
<VBox fx:id="setsArea" />
</children></AnchorPane>
</items>
@FXML
private VBox setsArea;
public void addSet(CardSet set){
for (Card card : set.getCards()) {
ImageView imageView = new ImageView(card.getImgUrl());
setsArea.getChildren().add(imageView);
}
setViews.put(set, setView);
}