When using Java 6, the ClosableTabbedPane fails with a ArrayIndexOutOfBoundsException when you try to close it using its [X] button.
Exception in thread "AWT-EventQueue-0"
java.lang.ArrayIndexOutOfBoundsException: 1 >= 1
at java.util.Vector.elementAt(Unknown Source)
at javax.swing.JTabbedPane.getIconAt(Unknown Source)
at
org.xnap.commons.gui.CloseableTabbedPane.setButtonVisible(CloseableTabbedPane.java:492)
at
org.xnap.commons.gui.CloseableTabbedPane.access$500(CloseableTabbedPane.java:62)
at
org.xnap.commons.gui.CloseableTabbedPane$SelectionHandler.stateChanged(CloseableTabbedPan
e.java:504)
at
javax.swing.DefaultSingleSelectionModel.fireStateChanged(Unknown Source)
at
javax.swing.DefaultSingleSelectionModel.setSelectedIndex(Unknown Source)
at javax.swing.JTabbedPane.setSelectedIndexImpl(Unknown Source)
at javax.swing.JTabbedPane.removeTabAt(Unknown Source)
at
org.xnap.commons.gui.CloseableTabbedPane.removeTabAt(CloseableTabbedPane.java:517)
at javax.swing.JTabbedPane.remove(Unknown Source)
Well, I commented out the call to setButtonVisible() which hides the old index button (see below) ...
private class SelectionHandler implements ChangeListener
{
int oldIndex = -1;
public void stateChanged(ChangeEvent e) {
// GSK: commented out these three lines for JDK6
// if (oldIndex != -1) {
// setButtonVisible(oldIndex, false);
// }
oldIndex = getSelectedIndex();
if (oldIndex != -1) {
setButtonVisible(oldIndex, true);
}
}
}
This fixes the array index out of bounds exception and doesn't appear to adversely affect the operation of the tabs.
Diff of change made to ClosableTabbedPane (code commented out).
Logged In: NO
Fixed in CVS.
Logged In: YES
user_id=165597
Originator: NO
Fix released in version 0.9.6.