Thursday, April 21, 2011

Children in Enumeration

Hello

I have a enumeration for elements in a JTree

When I find some specific element in this JTree, I want to check it's children. Do the method children() in a Enumeration check it's grandcildren too?

For example, let's supose this JTree, considering the identation as new levels of the tree:

  • Fruits
    • apple
    • grape
      • orange
      • peach
        • pineapple
      • strawberry
    • banana

If I get the children of grape, will I have just orange, peach and strawberry or will I get peach children (pineaple) too?

From stackoverflow
  • You will just have orange and peach - you would need to check them for their children (grandchildren of the original node).


    Edit: As derivation noted, you will also get Strawberry as that is a first level child - but the grandchildren will not be included in the enumeration.

    derivation : Think he will get strawberry too!
  • You would just get orange, peach and strawberry. As a side note for future reference, this kind of behavior is almost a de facto.

0 comments:

Post a Comment