在JavaFX中更改嵌套控制器

时间:2016-12-13 14:28:51

标签: java javafx controller

我正在使用嵌套控制器,我想将Login.fxml更改为Register.fxml,如图所示。

我们是否有方法可以执行此操作,或者我应该在Dashboard中加载Register.fxml并添加多个子项并设置visible属性?

Dashboard.fxml:

<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="900.0" prefWidth="1600.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1" fx:controller="controller.DashboardController">
   <left>
       <VBox prefHeight="200.0" prefWidth="285.0" BorderPane.alignment="CENTER">
           <children>
               <fx:include fx:id="login" source="Login.fxml" />
           </children>
       </VBox>
   </left>
   <center>
      <AnchorPane prefHeight="900.0" prefWidth="1315.0" BorderPane.alignment="CENTER_RIGHT">
         <children>
            <ImageView fitHeight="900.0" fitWidth="1315.0" layoutX="180.0" pickOnBounds="true" preserveRatio="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
            <Button fx:id="minimizeButton" layoutX="1243.0" layoutY="12.0" mnemonicParsing="false" onAction="#performMinimizeWindow" text="_" AnchorPane.rightAnchor="50.0" AnchorPane.topAnchor="10.0" />
            <Button fx:id="closeButton" layoutX="1278.0" layoutY="12.0" mnemonicParsing="false" onAction="#performCloseWindow" text="X" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0" />
         </children>
         <BorderPane.margin>
            <Insets />
         </BorderPane.margin>
      </AnchorPane>
   </center>
</BorderPane>

enter image description here

0 个答案:

没有答案