title: Dynamically add TextFields and Labels on a Combox Event
body: <p>I've made an app that works fine but I wan't to add a function and to do so I need to add some TextFields and Label when we change the value of a combobox.
  Here is my main code :</p>
  
  <pre><code>import javafx.application.Application;
  import javafx.fxml.FXMLLoader;
  import javafx.scene.Scene;
  import javafx.stage.Stage;
  import javafx.scene.Parent;
  
  
  public class maincombo extends Application {
  
      @Override
      public void start(Stage stage) throws Exception {
          Parent parent = FXMLLoader.load(getClass().getResource("/combobox.fxml"));
          Scene scene = new Scene(parent);
          stage.setTitle("Application");
          stage.setScene(scene);
          stage.show();
  
  }
  }
  </code></pre>
  
  <p>My controller : </p>
  
  <pre><code>import java.net.URL;
  import java.util.ResourceBundle;
  
  import javafx.collections.FXCollections;
  import javafx.collections.ObservableList;
  import javafx.event.ActionEvent;
  import javafx.fxml.FXML;
  import javafx.fxml.Initializable;
  import javafx.scene.control.ComboBox;
  
  public class comboboxcontroller implements Initializable {
  
      @FXML
      private ComboBox&lt;Integer&gt;methode;
      ObservableList&lt;Integer&gt;nombre = FXCollections.observableArrayList();
      @FXML
      private void metho (ActionEvent event){
          switch (methode.getValue()) {
          case 0 :
  
              break;
          case 1 :
              break;
          case 2 :
  
              break;
          case 3 :
  
  
              break;
          case 4 :
  
              break;
          case 5 :
  
              break;
          default :
  
              break;
          }
      }
  
      public comboboxcontroller (){
  
      }
  
  
      public void initialize(URL url,ResourceBundle rb){
  
          nombre.add(new Integer(0));
          nombre.add(new Integer(1));
          nombre.add(new Integer(2));
          nombre.add(new Integer(3));
          nombre.add(new Integer(4));
          nombre.add(new Integer(5));
          methode.setItems(nombre);
      }
  }
  </code></pre>
  
  <p>My fxml : </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;?import javafx.geometry.*?&gt;
  &lt;?import java.lang.*?&gt;
  &lt;?import javafx.scene.control.*?&gt;
  &lt;?import javafx.scene.layout.*?&gt;
  &lt;?import javafx.scene.layout.AnchorPane?&gt;
  
  &lt;AnchorPane prefHeight="150.0" prefWidth="150.0" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1" fx:controller="comboboxcontroller"&gt;
     &lt;children&gt;
        &lt;GridPane layoutX="-180.0" layoutY="-205.0" prefHeight="0.0" prefWidth="20.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"&gt;
          &lt;columnConstraints&gt;
            &lt;ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /&gt;
          &lt;/columnConstraints&gt;
          &lt;rowConstraints&gt;
            &lt;RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /&gt;
            &lt;RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /&gt;
          &lt;/rowConstraints&gt;
           &lt;children&gt;
              &lt;ComboBox fx:id="methode" prefWidth="150.0" GridPane.rowIndex="1"&gt;
                 &lt;GridPane.margin&gt;
                    &lt;Insets left="5.0" right="5.0" /&gt;
                 &lt;/GridPane.margin&gt;
              &lt;/ComboBox&gt;
              &lt;Label text="MyComboBox" GridPane.halignment="CENTER" GridPane.valignment="CENTER" /&gt;
           &lt;/children&gt;
        &lt;/GridPane&gt;
     &lt;/children&gt;
  &lt;/AnchorPane&gt;
  </code></pre>
  
  <p>I tried to do something with a switch statement, but it didn't work. What I want is when the user chooses the value 4, then I want it to add 4 labels and Textfields, but if he changes his mind and instead chooses a value of 2 it should show 2 labels and textfields.</p>
  
  <p><strong>Edit :</strong> I tried to put all my 5 TextFields and Labels and try to hide them with this line : </p>
  
  <pre><code>MyTextField.setVisible(false);
  </code></pre>
  
  <p>But everything still visible. So I started to think that maybe it's easier to add them dynamically or maybe with a pop-up window. And that why I here looking for a help.</p>