• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JTree - collapsePath issue

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



/**
* @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 ]
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I couldn't get your method to generate the exception you sited. Since the exception seems to have started with the 'collapsePath' call I would slip in a println statement to inspect what is coming into its test statement

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic