• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTree TreeExpansionListener problem  RSS feed

Martin Asenov
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys!

I've got a JTree that represents file system structure. Because initializing the tree with the entire file system would take decades, I decided to do it according with the user's interaction with it. When the user selects a node, I call a certain prepareSubDirectories() method that loads two levels down the selected node and it works fine... But only with TreeSelectionListener.valueChanged() method. When it comes to using the very same thing with TreeExpansionListener.treeExpanded() (cause I've got to load levels also when the user only expands the tree), things don't work. The tree remains loaded as it was by the latest selection, and doesn't give a thing about calling the prepareSubDirectories() method. It really gets invoked, but the children don't seem to get loaded. Please, tell me what to do ...

Here is the code:

As you can see, the two listeners don't differ in performance.

Any help will be greatly appreciated!

Best Regards,
Martin Asenov
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!