Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8095644

[Accordion] Accordion throws IndexOutOfBoundsException after remove all panes

    XMLWordPrintable

Details

    Description

      I have this code in start method:

              Accordion accordion = new Accordion();
              accordion.setStyle("-fx-background-color: #FF0000");
              
              accordion.getPanes().add(new TitledPane("1", new AnchorPane()));
              accordion.getPanes().add(new TitledPane("2", new AnchorPane()));
              accordion.getPanes().add(new TitledPane("3", new AnchorPane()));
              accordion.getPanes().add(new TitledPane("4", new AnchorPane()));
              
              Button remove = new Button("remove");
              remove.setOnAction((event) -> {
                  if (accordion.getPanes().size() != 0)
                      accordion.getPanes().remove(0);
              });

              VBox vBox = new VBox(accordion, remove);
              VBox.setVgrow(remove, Priority.ALWAYS);
              
              Scene scene = new Scene(vBox);
              primaryStage.setScene(scene);
              primaryStage.show();


      Steps to exception:
      1) Expand pane "4" (or any other pane);
      2) Click remove 4 times (remove all panes);
      3) Click on red area;

      Stack trace:
      Exception in thread "JavaFX Application Thread" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
      at java.util.ArrayList.rangeCheck(ArrayList.java:638)
      at java.util.ArrayList.get(ArrayList.java:414)
      at com.sun.javafx.collections.ObservableListWrapper.get(ObservableListWrapper.java:87)
      at com.sun.javafx.scene.control.behavior.AccordionBehavior$AccordionFocusModel$1.changed(AccordionBehavior.java:170)
      at com.sun.javafx.scene.control.behavior.AccordionBehavior$AccordionFocusModel$1.changed(AccordionBehavior.java:160)
      at com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:347)
      at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:80)
      at javafx.beans.property.ReadOnlyBooleanPropertyBase.fireValueChangedEvent(ReadOnlyBooleanPropertyBase.java:72)
      at javafx.scene.Node$FocusedProperty.notifyListeners(Node.java:7486)
      at javafx.scene.Scene$15.invalidated(Scene.java:2076)
      at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:111)
      at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:145)
      at javafx.scene.Scene$KeyHandler.setFocusOwner(Scene.java:3910)
      at javafx.scene.Scene$KeyHandler.requestFocus(Scene.java:3956)
      at javafx.scene.Scene$KeyHandler.access$2200(Scene.java:3896)
      at javafx.scene.Scene.requestFocus(Scene.java:2040)
      at javafx.scene.Node.requestFocus(Node.java:7647)
      at com.sun.javafx.scene.control.behavior.AccordionBehavior.mousePressed(AccordionBehavior.java:152)
      at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:95)
      at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
      at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
      at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
      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.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
      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:204)
      at javafx.scene.Scene$MouseHandler.process(Scene.java:3746)
      at javafx.scene.Scene$MouseHandler.access$1800(Scene.java:3471)
      at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1695)
      at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2486)
      at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:314)
      at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:243)
      at java.security.AccessController.doPrivileged(Native Method)
      at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:345)
      at com.sun.glass.ui.View.handleMouseEvent(View.java:526)
      at com.sun.glass.ui.View.notifyMouse(View.java:898)
      at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
      at com.sun.glass.ui.win.WinApplication.access$300(WinApplication.java:39)
      at com.sun.glass.ui.win.WinApplication$4$1.run(WinApplication.java:112)
      at java.lang.Thread.run(Thread.java:745)

      Attachments

        Activity

          People

            jgiles Jonathan Giles
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported: