title: View navigation in GroovyFX
body: <p>I'd like to adapt a MVVM WPF app to GroovyFX. I don't have so much experience in Groovy nor in GroovyFX itself, and there isn't so much information available.</p>
  
  <p>The design consist in a main window with a panel inside. When the user, let's say, pushes a button the app deletes the central panel children and inserts the new "node tree" that conforms the target view.</p>
  
  <p>Let's see some code</p>
  
  <pre><code>import groovyx.javafx.GroovyFX
  import groovyx.javafx.SceneGraphBuilder
  import static groovyx.javafx.GroovyFX.start
  import javafx.fxml.FXMLLoader
  import javafx.scene.layout.StackPane;
  
  def controller = new MainWindowController()
  def loader = new FXMLLoader(getClass().getResource("gui.fxml"));
  def myPane = loader.load();
  
  start
  {
      stage(title: "Tasks!", x: 100, y: 100, width: 400, height: 400, visible: true,
          style: "decorated", onHidden: { println "Close"})
      {
          scene(fill: GROOVYBLUE)
          {
              vbox(spacing: 10, padding: 10)
              {
                  button(text:"Show!",onAction:{ controller.activityPanel.getChildren().clear() controller.activityPanel.getChildren().add(myPane)})
                  controller.activityPanel=stackPane()
              }
          }
       }
  }
  </code></pre>
  
  <p>When the user presses the button the stackPane located inside the main window receives the contents of myPane and this "view" is shown.
  The question is</p>
  
  <ol>
  <li>How can I define this view "myPane" by code? I have only found the fxml solution.</li>
  <li>If the fxml is the only way, do you know any sample code about how to instantiate a controller class and bind its members using GroovyFX?</li>
  </ol>
  
  <p>This idea is similar to the jfx-flow project but in GroovyFX.</p>