1 Reply Latest reply on Jul 17, 2012 4:06 PM by morgalr

    Lazzy Loading implementation for DefaultTreeModel.


      We have a requirement in which we need to perform lazzy loading of the nodes in a DefaultTreeModel. In the current scenario the node and its child both are fetched and then node is created using DefaultMutableTreeNode and then added to instance of DefaultTreeModel. This had a performance hit and this had to replaced with lazzy loading. Now the child node information is not fetched instead a boolean variable isChildPresent is populate based on child node is present or not.

      In the current scenario when ever a child node is present the parent automatically used to get a + sign on the left had side. But now we are not adding the child node
      Based on the value of the isChildPresent we need to show/hide the +sign.

      One option was to override the isleaf API and always return false, this way + sign will be default displayed, but this approach is buggy as if the node doesnot have a child and then + sign is displayed will mislead the end user.

      Is there any other option to display the + sign based on the value of isChildPresent?