Hi Pankaj,
You can do this in this way:
Do Until treeNodeExists(tree, itemPath)
Delay 500
Loop
Here is the code of the
treeNodeExists script routine along with a sample of its usage:
Sub Test
Set tree = Sys.Process("javaw").SwingObject("JFrame", "SwingSet2", 0).SwingObject("JRootPane", "", 0).SwingObject("null.layeredPane").SwingObject("null.contentPane").SwingObject("SwingSet2", "", 0).SwingObject("JTabbedPane", "Tree Demo", 0).SwingObject("JPanel", "", 0).SwingObject("JPanel", "", 0).SwingObject("JScrollPane", "", 0).SwingObject("JViewport", "", 0).SwingObject("TreeDemo$1", "", 0)
itemPath = "Music|Classical|Mozart"
If treeNodeExists(tree, itemPath) Then
Log.Message("Node exists")
Else
Log.Error("Node does not exist")
End If
End Sub
Function treeNodeExists(tree, itemPath)
itemNames = split(itemPath, "|")
currentItem = itemNames(0)
If IsSupported(tree, "wItems") Then
Set items = tree.wItems
Else
Set items = tree.Items
End If
For i = 0 To items.Count - 1
If items.Item(i).Text = currentItem Then
If UBound(itemNames) = 0 Then
treeNodeExists = True
Else
treeNodeExists = treeNodeExists(items.Item(i), Join(removeFirstItemFromArray(itemNames), "|"))
End If
Exit Function
End If
Next
treeNodeExists = False
End Function
Function removeFirstItemFromArray(arr)
ReDim result(UBound(arr) - 1)
For i = 1 To UBound(arr)
result(i-1) = arr(i)
Next
removeFirstItemFromArray = result
End Function