• 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

Any tips on how to generate a huge jTree without getting a StackOverflowError?

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any tips on how to generate a huge jTree without getting a StackOverflowError? The tree shows navigation through a large Web site so the tree is going to be very large. The only thing I can think of it to generate each node's children as that node is clicked on (TreeWillExpandListener) rather than trying to create the entire tree at once. However, if you were to open all of the branches using this method, would you still get a StackOverflowError?
thanks!
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It sounds like you're creating the tree using a recursive algorithm; you just need to change it to be iterative instead. For example, use something like (in pseudocode)


[ April 19, 2005: Message edited by: Ernest Friedman-Hill ]
 
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wouldn't think you would get a StackOverflowError from creating a large JTree. I would expect an OutOfMemoryError if it was too large. I wonder if you are getting into an infinite loop that is causing the StackOverflowError. You say this show navigation through a web site, is there a link back to a previous page causing a loop?
 
Max Simpson
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Its not an infinite loop, but it is a loop that runs for a long time.. it seems like the VM thinks the loop has been running too long and throws the error.
The problem is that there are multiple ways to get to a single page, so various branches will include that page and any of its children. I have it set up so inside of a branch it will not repeat any pages it already added as nodes in that same branch.
I'm not sure what to try next :-(
 
I think she's lovely. It's this tiny ad that called her crazy:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic