From: Greg K. <gk...@po...> - 2006-12-12 07:24:08
|
Greg Kopff wrote: > ClosableTabbedPane.removeTabAt(): index: 0 > ClosableTabbedPane.removeTabAt(): getting icon at: 0 ... > ClosableTabbedPane.removeTabAt(): ... got icon > ClosableTabbedPane.removeTabAt(): calling super.removeTabAt() ... > ClossableTabbedPane.SelectionHandler.stateChanged(): entry. > ClossableTabbedPane.SelectionHandler.stateChanged(): setting button > hidden ... > ClosableTabbedPane.setButtonVisible(): index: 0 visible: false > Exception in thread "AWT-EventQueue-0" > java.lang.ArrayIndexOutOfBoundsException: 0 >= 0 > at java.util.Vector.elementAt(Unknown Source) > at javax.swing.JTabbedPane.getIconAt(Unknown Source) > > It looks like we get a tab change event and use that to hide the right > hand side "event icon" ... > > ... however, it would appear that in JDK 6 the tab is already gone at > this point. > > Does anyone more knowledgeable have an idea how to make this work? Hi again. 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. My guess is that when the tab goes away, so does its button anyway. Can anyone confirm or deny this? Is it an acceptable fix? :-) Kindest regards, -- Greg Kopff =================================================== gk...@po... PowerSource Software Chief Technologist http://www.powersource.com.au =================================================== did you know 'if' is the middle word in 'life'? =================================================== Typhoon a revolution in wagering & gaming http://www.typhoon.com.au/ =================================================== |