/**
* @desc Makes sure that only the given tree node path is expanded.
*/
private void singleExapand( TreePath prmNdPath ) {
Enumeration expandedPaths = this.getExpandedDescendants( new TreePath( _rootNode.getPath() ) );
boolean bExpandNode = true;
if( null != expandedPaths ) {
while( expandedPaths.hasMoreElements() ) {
TreePath expdPath = ( TreePath )expandedPaths.nextElement();
if( !prmNdPath.equals( expdPath ) ) {
this.collapsePath( expdPath );
bExpandNode = false;
}
}
}
oldPath = prmNdPath;
if( bExpandNode ) {
this.expandPath( prmNdPath );
this.scrollPathToVisible( prmNdPath );
}
}
output (sometimes - not reproducible always)
java.lang.ArrayIndexOutOfBoundsException: 2 >= 1
at java.util.Vector.removeElementAt(Unknown Source)
at javax.swing.tree.VariableHeightLayoutCache$TreeStateNode.collapse(Unknown Source)
at javax.swing.tree.VariableHeightLayoutCache$TreeStateNode.collapse(Unknown Source)
at javax.swing.tree.VariableHeightLayoutCache.setExpandedState(Unknown Source)
at javax.swing.plaf.basic.BasicTreeUI$TreeExpansionHandler.treeCollapsed(Unknown Source)
at javax.swing.JTree.fireTreeCollapsed(Unknown Source)
at javax.swing.JTree.setExpandedState(Unknown Source)
at javax.swing.JTree.collapsePath(Unknown Source)
Hi all,
My aim is to allow single node expansion on a JTree component. Above is the abstract from a class which I extended from JTree.
Would any one let me know if there is any thing I'am missing in the above code.
Whenever I try to load my tree component this exception comes.
The above exception is not reproducible all the time only some times.
any guesses whether why this happens?
Thank you,
Sainath Veepuri
[ October 04, 2005: Message edited by: Sainath Veepuri ]