2

I am working with nested controller and I want to change the Login.fxml to a Register.fxml as you can see in image.

Do we have a method to do it or I should load Register.fxml in Dashboard and add multiple children and set the visible property?

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

Marckaraujo
  • 7,422
  • 11
  • 59
  • 97
  • By "work with hide" I guess you mean add multiple children and set the `visible` property of all but one of those children to `false` or something like that? Please improve the description of the desired behavior in the question. – fabian Dec 13 '16 at 14:33
  • @fabian, yes thats it – Marckaraujo Dec 13 '16 at 14:35
  • Possible duplicate of: [Loading new fxml in the same scene](http://stackoverflow.com/questions/18619394/loading-new-fxml-in-the-same-scene) – jewelsea Dec 13 '16 at 18:46
  • @jewelsea, this workaround works but you need an extra class and dont allow you to use fx:include – Marckaraujo Dec 13 '16 at 18:56

0 Answers0