Forum Discussion

shankar_r's avatar
shankar_r
Community Hero
10 years ago

How can i click JSwing tree item

I am having a JavaSwing Tree object and it is having lots of sub item and each sub item having multiple sub items. 

 

For Ex:

 

TreeObject

1.TreeItem1

   1.1 MainTopic

       1.1.1 TestTopic

          1.1.1.1 HaveToClick

2. TreeItem2

   2.1 MainTopic

       2.1.1 TestTopic

       2.1.2 HaveToClick1

 

In this tree, I don't know the item HaveToClick1 and  HaveToClick are in which sub item. But i need to click dynamically HaveToClick1 and HaveToClick.

 

I went through the tutorial available in Selecting Tree View Items. but no luck

 

Any solutions?

 

 

9 Replies

  • cunderw's avatar
    cunderw
    Community Hero

    If there are any static properties that would uniquely identify them you could use FindChild to find the matching item. 

    • shankar_r's avatar
      shankar_r
      Community Hero

      I know only the Text of the particular tree item nothing else.

       

      If i want to find a tree item based on its text, How i can do that.

       

      And the tree items are nested so i don't know on which thisngs it theres

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        FindChild and related methods allow you to search in your tree of objects for any child given a particular set of properties. So, if you only know the text, you would call something like

         

        ...
        
        var PropertyList = new Array("Text")
        var PropertyValues = new Array("MyText")
        ...
        
        var MyTreeItem = ParentObj.FindChild(PropertyList, PropertyValues, 5)
        

        See FindChild Method