在javafx中,如何在具有不同fxml文件的功能之间进行更改?

在javafx中,如何在具有不同fxml文件的功能之间进行更改?,java,css,xml,javafx,Java,Css,Xml,Javafx,下面是程序现在的样子 最终,我将有图标在功能之间导航。我遇到的问题是,我不知道如何更改fxml文件以显示不同的功能,而不同时加载它们,然后使它们可见和不可见 下面是Frame.fxml代码,其中包含我们的第一个功能。您可以看到我们有FrameTopController和FrameLeftController,FrameRightController这构成了搜索功能。最终我们会有更多的功能,但我不知道从哪里开始。如果可能,所有功能都将放置在Frame.fxml中 ` <?xml versio

下面是程序现在的样子

最终,我将有图标在功能之间导航。我遇到的问题是,我不知道如何更改fxml文件以显示不同的功能,而不同时加载它们,然后使它们可见和不可见

下面是Frame.fxml代码,其中包含我们的第一个功能。您可以看到我们有FrameTopController和FrameLeftController,FrameRightController这构成了搜索功能。最终我们会有更多的功能,但我不知道从哪里开始。如果可能,所有功能都将放置在Frame.fxml中

` <?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.text.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.*?>
<?import javafx.scene.effect.*?>
<?import javafx.scene.web.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.control.TextField?>
<?import nutritionAPIV2_controllers.*?>

<fx:root maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="549.0" prefWidth="832.0" type="javafx.scene.layout.AnchorPane" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
    <children>

        <!-- Top Panel -->

      <StackPane layoutY="70.0" prefHeight="479.0" prefWidth="832.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="70.0">
         <children>
          <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="473.0" prefWidth="832.0">
               <children>
                  <SplitPane fx:id="navMenuPane" dividerPositions="0.0036144578313253013" layoutY="1.0" prefHeight="442.0" prefWidth="832.0" AnchorPane.bottomAnchor="6.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="1.0">
                    <items>
                      <AnchorPane fx:id="navMenu" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="0.0" minWidth="0.0" prefHeight="456.0" prefWidth="71.0" SplitPane.resizableWithParent="false" />
                      <AnchorPane fx:id="LeftandRightAnchor" minHeight="0.0" minWidth="0.0" prefHeight="489.0" prefWidth="763.0">
                           <children>
                              <HBox fx:id="LeftAndRightPanel" alignment="CENTER" layoutY="-9.0" prefHeight="479.0" prefWidth="824.0" spacing="1.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="-9.0">
                                 <children>
                                            <!-- Created by Brandon VanderMeyf May 20 2015 -->


                                                    <!-- Left Panel -->

                                                    <FrameBottomLeftController fx:id="frameBottomLeftController" />

                                                    <!--  Right Panel -->

                                                    <FrameBottomRightController fx:id="frameBottomRightController" />



                                 </children>
                              </HBox>
                           </children>
                        </AnchorPane>
                    </items>
                  </SplitPane>
               </children>
            </AnchorPane>
         </children></StackPane>
            <Pane prefHeight="64.0" prefWidth="833.0" style="-fx-background-color: #8bc34a;" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="-1.0" AnchorPane.topAnchor="0.0">
               <children>
               <FrameTopController fx:id="frameTopController" layoutX="450.0" layoutY="20.0" />
                  <AnchorPane layoutX="14.0" layoutY="19.0">
                     <children>
                        <Button id="menuButton" fx:id="menuButton" mnemonicParsing="false" opacity="0.37" prefHeight="38.0" prefWidth="38.0">
                           <effect>
                              <ImageInput>
                                 <source>
                                    <Image url="/resources/menuButton.png" />
                                 </source>
                              </ImageInput>
                           </effect>
                        </Button>
                        <Label layoutX="45.0" layoutY="-3.0"      prefHeight="35.0" prefWidth="216.0" text="I'm A Program" textFill="WHITE">
                           <font>
                              <Font name="SansSerif Regular" size="24.0" />
                           </font>
                        </Label>
                     </children>
                  </AnchorPane>
               </children>
            </Pane>

    </children>
    </fx:root>`
`

您能详细说明一下更改xml是什么意思吗?您正在使用fxml和scenebuilder吗?使用fx:include,但我不确定这是否是你要问的。真的不清楚你要问什么。我建议您通读其中一些,并编辑您的问题,使其更清晰。您能详细说明一下更改xml是什么意思吗?您正在使用fxml和scenebuilder吗?使用fx:include,但我不确定这是否是你要问的。真的不清楚你要问什么。我建议你通读其中一些,并编辑你的问题,使其更清晰。