ArrayIndexOutOfBoundsException

When I close my application the following exception is thrown:

12:43:34.141 ERROR Exception in thread Thread[AWT-EventQueue-0,6,main]
java.lang.ArrayIndexOutOfBoundsException: 2 >= 2
at java.util.Vector.elementAt(Vector.java:427)
at javax.swing.JTabbedPane.setForegroundAt(JTabbedPane.java:1465)
at bibliothek.gui.dock.themes.basic.BasicStackDockComponent$BasicTab.recolor(BasicStackDockComponent.java:142)
at bibliothek.gui.dock.themes.basic.BasicStackDockComponent$BasicTab.dockableFocused(BasicStackDockComponent.java:148)
at bibliothek.gui.DockController.fireDockableFocused(DockController.java:1173)
at bibliothek.gui.DockController.setFocusedDockable(DockController.java:743)
at bibliothek.gui.dock.common.intern.EfficientControlFactory$1.setFocusedDockable(EfficientControlFactory.java:60)
at bibliothek.gui.DockController.setFocusedDockable(DockController.java:675)
at bibliothek.gui.dock.StackDockStation$VisibleListener.stateChanged(StackDockStation.java:898)
at javax.swing.JTabbedPane.fireStateChanged(JTabbedPane.java:400)
at javax.swing.JTabbedPane$ModelListener.stateChanged(JTabbedPane.java:253)
at javax.swing.DefaultSingleSelectionModel.fireStateChanged(DefaultSingleSelectionModel.java:116)
at javax.swing.DefaultSingleSelectionModel.setSelectedIndex(DefaultSingleSelectionModel.java:50)
at javax.swing.JTabbedPane.setSelectedIndexImpl(JTabbedPane.java:599)
at javax.swing.JTabbedPane.removeTabAt(JTabbedPane.java:952)
at javax.swing.JTabbedPane.remove(JTabbedPane.java:1028)
at bibliothek.gui.dock.station.stack.DefaultStackDockComponent.remove(DefaultStackDockComponent.java:113)
at bibliothek.gui.dock.StackDockStation.remove(StackDockStation.java:814)
at bibliothek.gui.dock.StackDockStation.drag(StackDockStation.java:694)
at bibliothek.gui.DockFrontend.hide(DockFrontend.java:832)
at bibliothek.gui.dock.common.CControl$Access.hide(CControl.java:1746)
at bibliothek.gui.dock.common.intern.AbstractCDockable.setVisible(AbstractCDockable.java:207)
at bibliothek.gui.dock.common.CControl.remove(CControl.java:1225)

On the west side of the screen, I have three dockables in a tabpanel. For each dockable I call ccontrol.remove(dockable).

FYI,

It is the first remove of a dockable that is going wrong,
I see still two tabs on the screen.

Alright, thanks for the note.

BTW, the exception only occurs when you have more than two dockables in the tab panel

I was not able to reproduce the error, but I’ve added an additional “if” before setting the color, so this should not happen again.

Could you check in the code?
Then I will test it :wink:

Oh, sorry.
Done.

That solved the problem, thanks