无法在右下角放置按钮

问题描述 投票:0回答:2

在场景生成器中,预览按钮位于确切的位置,即右下角,没有任何间隙,但是当我运行我的应用程序时,存在间隙。Scene builder previewIn application view

按钮位于窗格中,并且窗格位于锚定窗格的顶部。我该如何解决这个问题?当我将其他组件放在最右端或最下端时,其他组件也会发生相同的情况。

javafx scenebuilder
2个回答
1
投票
<?xml version="1.0" encoding="UTF-8"?> <?import javafx.geometry.Insets?> <?import javafx.scene.control.Button?> <?import javafx.scene.control.Label?> <?import javafx.scene.control.TextField?> <?import javafx.scene.layout.ColumnConstraints?> <?import javafx.scene.layout.GridPane?> <?import javafx.scene.layout.HBox?> <?import javafx.scene.layout.RowConstraints?> <?import javafx.scene.layout.StackPane?> <?import javafx.scene.layout.VBox?> <HBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1"> <children> <VBox style="-fx-background-color: yellow;"> <children> <StackPane VBox.vgrow="ALWAYS"> <children> <Button mnemonicParsing="false" text="Menu Button" /> </children> </StackPane> <StackPane VBox.vgrow="ALWAYS"> <children> <Button mnemonicParsing="false" text="Menu Button" /> </children> </StackPane> <StackPane layoutX="10.0" layoutY="210.0" VBox.vgrow="ALWAYS"> <children> <Button mnemonicParsing="false" text="Menu Button" /> </children> </StackPane> <StackPane layoutX="10.0" layoutY="276.0" VBox.vgrow="ALWAYS"> <children> <Button mnemonicParsing="false" text="Menu Button" /> </children> <VBox.margin> <Insets /> </VBox.margin> </StackPane> <StackPane layoutX="10.0" layoutY="310.0" VBox.vgrow="ALWAYS"> <children> <Button mnemonicParsing="false" text="Menu Button" /> </children> </StackPane> </children> </VBox> <VBox style="-fx-background-color: red;" HBox.hgrow="ALWAYS"> <children> <StackPane prefHeight="150.0" prefWidth="200.0" style="-fx-background-color: green;" VBox.vgrow="ALWAYS"> <children> <GridPane maxHeight="-Infinity" maxWidth="-Infinity" style="-fx-background-color: purple;"> <columnConstraints> <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> </columnConstraints> <rowConstraints> <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> </rowConstraints> <children> <Label text="Label" /> <TextField GridPane.columnIndex="1" /> <TextField GridPane.columnIndex="1" GridPane.rowIndex="1" /> <TextField GridPane.columnIndex="1" GridPane.rowIndex="2" /> <Label text="Label" GridPane.rowIndex="1" /> <Label text="Label" GridPane.rowIndex="2" /> </children> </GridPane> </children> </StackPane> <HBox alignment="TOP_RIGHT"> <children> <Button mnemonicParsing="false" text="Button" /> </children> </HBox> </children> </VBox> </children> </HBox>

0
投票
© www.soinside.com 2019 - 2024. All rights reserved.