Błędy po uruchomieniu aplikacji napisanej w JavaFX

0

Siema, co może być nie tak z tym kodem?

package fourprogrammers_guiexample;

import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Pos;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class FourProgrammers_GUIExample extends Application {

    private HBox hBox;
    private VBox vBoxSet_1;
    private VBox vBoxSet_2;

    public Parent createContent() {

        /* layout */
        BorderPane layout = new BorderPane();

        /* layout -> center */
        hBox = new HBox(30);

        /* layout -> center -> left */
        VBox vBoxLeft = new VBox(10);

        ObservableList<String> ol = FXCollections.observableArrayList("Set 1", "Set 2");
        ComboBox<String> cbSets = new ComboBox<String>(ol);
        cbSets.setOnAction(ae -> {
            if (cbSets.getSelectionModel().getSelectedItem().equals("Set 1")) {
                hBox.getChildren().set(1, vBoxSet_1);
            } else {
                hBox.getChildren().set(1, vBoxSet_2);
            }
        });
        cbSets.getSelectionModel().select("Set 1");

        /* layout -> center -> left (add items) */
        vBoxLeft.getChildren().addAll(cbSets);
        vBoxLeft.setAlignment(Pos.CENTER);

        /* layout -> center -> right */

        /* layout -> center -> right -> set 1*/
        vBoxSet_1 = new VBox(10);
        Button button_1 = new Button("Button 1");
        Button button_2 = new Button("Button 2");
        Button button_3 = new Button("Button 3");
        Button button_4 = new Button("Button 4");

        /* layout -> center -> right -> set 1 (add items) */
        vBoxSet_1.getChildren().addAll(button_1, button_2, button_3, button_4);
        vBoxSet_1.setAlignment(Pos.CENTER);

        /* layout -> center -> right -> set 2*/
        vBoxSet_2 = new VBox(10);
        Button button_5 = new Button("Button 5");
        Button button_6 = new Button("Button 6");
        Button button_7 = new Button("Button 7");
        Button button_8 = new Button("Button 8");

        /* layout -> center -> right -> set 2 (add items) */
        vBoxSet_2.getChildren().addAll(button_5, button_6, button_7, button_8);
        vBoxSet_2.setAlignment(Pos.CENTER);

        /* layout -> center (add items) */
        hBox.getChildren().addAll(vBoxLeft, vBoxSet_1);
        hBox.setAlignment(Pos.CENTER);

        /* return layout */
        layout.setCenter(hBox);
        return layout;
    }

    @Override
    public void start(Stage stage) throws Exception {
        stage.setScene(new Scene(createContent()));
        stage.setWidth(200);
        stage.setHeight(200);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}

Program działa, ale wywala takie coś po uruchomieniu:

jfx-project-run:
Executing C:\Users\Witek\Documents\NetBeansProjects\FourProgrammers_GUIExample\dist\run2081846028\FourProgrammers_GUIExample.jar using platform C:\Program Files\Java\jdk1.8.0_31\jre/bin/java
Exception in thread "JavaFX Application Thread" java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
    at java.util.ArrayList.rangeCheck(ArrayList.java:653)
    at java.util.ArrayList.get(ArrayList.java:429)
    at com.sun.javafx.collections.ObservableListWrapper.get(ObservableListWrapper.java:89)
    at com.sun.javafx.collections.VetoableListDecorator.get(VetoableListDecorator.java:306)
    at javafx.scene.Parent$2.onProposedChange(Parent.java:419)
    at com.sun.javafx.collections.VetoableListDecorator.set(VetoableListDecorator.java:311)
    at fourprogrammers_guiexample.FourProgrammers_GUIExample.lambda$createContent$0(FourProgrammers_GUIExample.java:37)
    at fourprogrammers_guiexample.FourProgrammers_GUIExample$$Lambda$76/2093144363.handle(Unknown Source)
    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
    at javafx.event.Event.fireEvent(Event.java:198)
    at javafx.scene.Node.fireEvent(Node.java:8216)
    at javafx.scene.control.ComboBoxBase.valueInvalidated(ComboBoxBase.java:136)
    at javafx.scene.control.ComboBoxBase$1.invalidated(ComboBoxBase.java:161)
    at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:111)
    at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:145)
    at javafx.scene.control.ComboBoxBase.setValue(ComboBoxBase.java:167)
    at javafx.scene.control.ComboBox.updateValue(ComboBox.java:468)
    at javafx.scene.control.ComboBox.access$300(ComboBox.java:187)
    at javafx.scene.control.ComboBox$4.changed(ComboBox.java:453)
    at com.sun.javafx.binding.ExpressionHelper$SingleChange.fireValueChangedEvent(ExpressionHelper.java:182)
    at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81)
    at javafx.beans.property.ReadOnlyObjectWrapper$ReadOnlyPropertyImpl.fireValueChangedEvent(ReadOnlyObjectWrapper.java:176)
    at javafx.beans.property.ReadOnlyObjectWrapper.fireValueChangedEvent(ReadOnlyObjectWrapper.java:142)
    at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:112)
    at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:145)
    at javafx.scene.control.SelectionModel.setSelectedItem(SelectionModel.java:102)
    at javafx.scene.control.ComboBox$ComboBoxSelectionModel.lambda$new$152(ComboBox.java:499)
    at javafx.scene.control.ComboBox$ComboBoxSelectionModel$$Lambda$73/1976071531.invalidated(Unknown Source)
    at com.sun.javafx.binding.ExpressionHelper$SingleInvalidation.fireValueChangedEvent(ExpressionHelper.java:137)
    at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81)
    at javafx.beans.property.ReadOnlyIntegerWrapper$ReadOnlyPropertyImpl.fireValueChangedEvent(ReadOnlyIntegerWrapper.java:176)
    at javafx.beans.property.ReadOnlyIntegerWrapper.fireValueChangedEvent(ReadOnlyIntegerWrapper.java:142)
    at javafx.beans.property.IntegerPropertyBase.markInvalid(IntegerPropertyBase.java:113)
    at javafx.beans.property.IntegerPropertyBase.set(IntegerPropertyBase.java:146)
    at javafx.scene.control.SelectionModel.setSelectedIndex(SelectionModel.java:68)
    at javafx.scene.control.SingleSelectionModel.updateSelectedIndex(SingleSelectionModel.java:215)
    at javafx.scene.control.SingleSelectionModel.select(SingleSelectionModel.java:149)
    at javafx.scene.control.SingleSelectionModel.select(SingleSelectionModel.java:124)
    at fourprogrammers_guiexample.FourProgrammers_GUIExample.createContent(FourProgrammers_GUIExample.java:42)
    at fourprogrammers_guiexample.FourProgrammers_GUIExample.start(FourProgrammers_GUIExample.java:83)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$153(LauncherImpl.java:821)
    at com.sun.javafx.application.LauncherImpl$$Lambda$51/1102999613.run(Unknown Source)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$166(PlatformImpl.java:323)
    at com.sun.javafx.application.PlatformImpl$$Lambda$45/584634336.run(Unknown Source)
    at com.sun.javafx.application.PlatformImpl.lambda$null$164(PlatformImpl.java:292)
    at com.sun.javafx.application.PlatformImpl$$Lambda$47/1959779554.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(PlatformImpl.java:291)
    at com.sun.javafx.application.PlatformImpl$$Lambda$46/501263526.run(Unknown Source)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$141(WinApplication.java:102)
    at com.sun.glass.ui.win.WinApplication$$Lambda$37/96639997.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:745)
Deleting directory C:\Users\Witek\Documents\NetBeansProjects\FourProgrammers_GUIExample\dist\run2081846028
jfxsa-run:
BUILD SUCCESSFUL (total time: 24 seconds)

1 użytkowników online, w tym zalogowanych: 0, gości: 1, botów: 0