Menu

#3 ClosableTabbedPane fails when closed using Java 6

closed-fixed
5
2007-02-11
2006-12-13
Greg Kopff
No

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.

Discussion

  • Greg Kopff

    Greg Kopff - 2006-12-13

    Diff of change made to ClosableTabbedPane (code commented out).

     
  • Nobody/Anonymous

    Logged In: NO

    Fixed in CVS.

     
  • Steffen Pingel

    Steffen Pingel - 2007-02-11

    Logged In: YES
    user_id=165597
    Originator: NO

    Fix released in version 0.9.6.

     
  • Steffen Pingel

    Steffen Pingel - 2007-02-11
    • assigned_to: nobody --> squig
    • status: open --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB