title: Exception in Application start method: IndexOutOfBounds
body: <p>I can not find a solution to this Error, but I probably found out what is the cause. 
  I want to add multiple items to the VBox:</p>
  
  <pre><code>VBox vbox = new VBox();
  vbox.getChildren().addAll(ohlcBtn, labelOHLC, tradesBtn, labelTRADES);
  return vbox;
  </code></pre>
  
  <p>If I just add the first two items, everything works, but java can not access the third one 
  (probably that is why there is the java.lang.IndexOutOfBoundsException: Index: 3, Size: 2 )
  the error occurs on </p>
  
  <pre><code>primaryStage.show();
  </code></pre>
  
  <hr>
  
  <pre><code>Exception in Application start method
  java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:601)
      at com.javafx.main.Main.launchApp(Main.java:642)
      at com.javafx.main.Main.main(Main.java:805)
  Caused by: java.lang.RuntimeException: Exception in Application start method
      at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:403)
      at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47)
      at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
      at java.lang.Thread.run(Thread.java:722)
  Caused by: java.lang.IndexOutOfBoundsException: Index: 3, Size: 2
      at java.util.ArrayList.rangeCheck(ArrayList.java:604)
      at java.util.ArrayList.get(ArrayList.java:382)
      at com.sun.javafx.collections.ObservableListWrapper.get(ObservableListWrapper.java:208)
      at javafx.scene.Parent.impl_processCSS(Parent.java:1151)
      at javafx.scene.Parent.impl_processCSS(Parent.java:1153)
      at javafx.scene.Parent.impl_processCSS(Parent.java:1153)
      at javafx.scene.Node.processCSS(Node.java:7383)
      at javafx.scene.Scene.doCSSPass(Scene.java:446)
      at javafx.scene.Scene.preferredSize(Scene.java:1449)
      at javafx.scene.Scene.impl_preferredSize(Scene.java:1516)
      at javafx.stage.Window$9.invalidated(Window.java:716)
      at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:127)
      at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:161)
      at javafx.stage.Window.setShowing(Window.java:779)
      at javafx.stage.Window.show(Window.java:794)
      at javafx.stage.Stage.show(Stage.java:229)
      at javamt4interface.JavaMT4Interface.start(JavaMT4Interface.java:58)
      at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
      at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:215)
      at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
      at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
      at java.security.AccessController.doPrivileged(Native Method)
      at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
      at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
      at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
      at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
      ... 1 more
  Java Result: 1
  </code></pre>
  
  <hr>
  
  <p>I have put the relevant Methods here:</p>
  
  <pre><code>public class JavaMT4Interface extends Application {
  
      final InputOrganizer io = new InputOrganizer();
      private Scene scene;
  
      @Override
      public void start(Stage primaryStage) {
  
          Group root = new Group();
          primaryStage.setTitle("The Forex Project");
          scene = new Scene(root, 500, 250);
          primaryStage.setScene(scene);
  
          BorderPane borderPane = new BorderPane();
  
          borderPane.setTop(getTopContent());
          borderPane.setLeft(getLeftContent());
          root.getChildren().add(borderPane);
  
          primaryStage.show();
      }
  
  
      private Label labelOHLC;
      private Label labelTRADES;
  
    public Node getTopContent() {
          Button ohlcBtn = new Button();
          ohlcBtn.setId("ohlcFileChooser");
          ohlcBtn.setText("Choose OHLC File");
          labelOHLC = new Label("", ohlcBtn);
          labelOHLC.setId("ohlcFileChosen");
          labelOHLC.setContentDisplay(ContentDisplay.LEFT);
          ohlcBtn.setOnAction(new EventHandler&lt;ActionEvent&gt;() {
              @Override
              public void handle(ActionEvent event) {
                  FileChooser fc = new FileChooser();
                  File userDirectory = getThisDirectory();
                  fc.setInitialDirectory(userDirectory);
                  fc.setTitle("ohlcFile");
                  File ohlcFile = fc.showOpenDialog(new Popup());
                  if (ohlcFile != null) {
                      io.setOhlcFile(ohlcFile);
                      labelOHLC.setText(ohlcFile.getAbsolutePath());
                  } else {
                      showDialog("No file selected.");
                  }
              }
          });
  
          Button tradesBtn = new Button();
          tradesBtn.setId("tradesFileChooser");
          tradesBtn.setText("Choose Trade File");
          labelTRADES = new Label("", tradesBtn);
          labelTRADES.setId("ohlcFileChosen");
          labelTRADES.setContentDisplay(ContentDisplay.LEFT);
          tradesBtn.setOnAction(new EventHandler&lt;ActionEvent&gt;() {
              @Override
              public void handle(ActionEvent event) {
                  FileChooser fc = new FileChooser();
                  File userDirectory = getThisDirectory();
                  if (!userDirectory.canRead()) {
                      userDirectory = new File("c:/");
                  }
                  fc.setInitialDirectory(userDirectory);
                  fc.setTitle("Trade File");
                  File tradeFile = fc.showOpenDialog(new Popup());
                  if (tradeFile != null) {
                      io.setTradesFile(tradeFile);
                      labelTRADES.setText(tradeFile.getAbsolutePath());
                  } else {
                      showDialog("No file selected.");
                  }
              }
          });
  
          VBox vbox = new VBox();
          vbox.getChildren().addAll(ohlcBtn, labelOHLC, tradesBtn, labelTRADES);
          return vbox;
      }
  
  }
  </code></pre>
  
  <p>Thanks for your help! :)</p>