Layout 窗口大小调整时的动态x位置

Layout 窗口大小调整时的动态x位置,layout,javafx-8,Layout,Javafx 8,我有一个按钮。点击那个按钮。我正在打开它正下方的stackpane。用于StackPane硬编码的x布局值。因此,首先单击按钮正下方显示的stackpane。问题是当我最大化或调整窗口大小时,它并没有调整它的位置(x) FXML 我找到了覆盖下拉菜单的解决方案 <MenuButton mnemonicParsing="false" nodeOrientation="LEFT_TO_RIGHT"

我有一个按钮。点击那个按钮。我正在打开它正下方的stackpane。用于StackPane硬编码的x布局值。因此,首先单击按钮正下方显示的stackpane。问题是当我最大化或调整窗口大小时,它并没有调整它的位置(x)

FXML


我找到了覆盖下拉菜单的解决方案

                        <MenuButton mnemonicParsing="false" nodeOrientation="LEFT_TO_RIGHT"
                            styleClass="redButton" text="Search Criteria" textFill="WHITE">
                            <items>
                                <MenuItem mnemonicParsing="false"
                                    style="-fx-background-color: transparent; -fx-padding: 0; -fx-margin: 0;">

                                        <AnchorPane minHeight="0.0" minWidth="0.0"
                                            prefHeight="500.0" prefWidth="345.0" styleClass="noborder">
                                            <children>

                                                <HBox layoutY="156.0" minHeight="185.0" minWidth="345.0"
                                                    prefHeight="185.0" prefWidth="357.0" />

                                                <HBox layoutX="5.0" layoutY="316.0" prefHeight="35.0"
                                                    prefWidth="348.0">
                                                    <children>
                                                        <Text layoutX="7.0" layoutY="335.0" strokeType="OUTSIDE"
                                                            strokeWidth="0.0" text="Template Name">
                                                            <HBox.margin>
                                                                <Insets right="5.0" top="9.0" />
                                                            </HBox.margin>
                                                        </Text>
                                                        <ComboBox fx:id="templateNameComboBox" layoutX="94.0"
                                                            layoutY="330.0" prefWidth="248.0" promptText="Select Template Name">
                                                            <HBox.margin>
                                                                <Insets left="7.0" />
                                                            </HBox.margin>
                                                        </ComboBox>
                                                    </children>
                                                </HBox>


                                            </children>
                                        </AnchorPane>

                                </MenuItem>
                            </items>
                            <HBox.margin>
                                <Insets left="6.0" />
                            </HBox.margin>
                            <cursor>
                                <Cursor fx:constant="HAND" />
                            </cursor>
                        </MenuButton>


如果您发布MVCE,会更有帮助。我找到了解决方案。谢谢你,伙计。
@FXML
    private void searchCriteriaAction(ActionEvent event){

        searchCriteriaPane.visibleProperty().setValue(true);

        searchCriteriaBtn.layoutXProperty().bind(searchCriteriaPane.layoutXProperty());
        searchCriteriaBtn.layoutYProperty().bind(searchCriteriaPane.layoutYProperty());

    }
                        <MenuButton mnemonicParsing="false" nodeOrientation="LEFT_TO_RIGHT"
                            styleClass="redButton" text="Search Criteria" textFill="WHITE">
                            <items>
                                <MenuItem mnemonicParsing="false"
                                    style="-fx-background-color: transparent; -fx-padding: 0; -fx-margin: 0;">

                                        <AnchorPane minHeight="0.0" minWidth="0.0"
                                            prefHeight="500.0" prefWidth="345.0" styleClass="noborder">
                                            <children>

                                                <HBox layoutY="156.0" minHeight="185.0" minWidth="345.0"
                                                    prefHeight="185.0" prefWidth="357.0" />

                                                <HBox layoutX="5.0" layoutY="316.0" prefHeight="35.0"
                                                    prefWidth="348.0">
                                                    <children>
                                                        <Text layoutX="7.0" layoutY="335.0" strokeType="OUTSIDE"
                                                            strokeWidth="0.0" text="Template Name">
                                                            <HBox.margin>
                                                                <Insets right="5.0" top="9.0" />
                                                            </HBox.margin>
                                                        </Text>
                                                        <ComboBox fx:id="templateNameComboBox" layoutX="94.0"
                                                            layoutY="330.0" prefWidth="248.0" promptText="Select Template Name">
                                                            <HBox.margin>
                                                                <Insets left="7.0" />
                                                            </HBox.margin>
                                                        </ComboBox>
                                                    </children>
                                                </HBox>


                                            </children>
                                        </AnchorPane>

                                </MenuItem>
                            </items>
                            <HBox.margin>
                                <Insets left="6.0" />
                            </HBox.margin>
                            <cursor>
                                <Cursor fx:constant="HAND" />
                            </cursor>
                        </MenuButton>