'Set the background color of a treeview cell depending its value.
'Note: Ensure to expand all items and use subdelayed after treeview been build
'Example: CallSubDelayed3(Me, "SetTreeCellsBackgroundColor2", TreeView1, 20)
Sub SetTreeCellsBackgroundColor2(tv As TreeView, threshold As Int) 'ignore
Dim joTV As JavaObject = tv
'Get all treecells
Dim joTCL As JavaObject = joTV.RunMethodJo("lookupAll", Array(".tree-cell"))
'Add those to an arraylist
Dim joAL As JavaObject
joAL.InitializeNewInstance("java.util.ArrayList", Array(joTCL))
'Create a List
Dim l As List = joAL
'Set the color of the treecells
For i = 0 To l.size - 1
'Get the treecell
Dim joIP As JavaObject = l.Get(i)
'Get the treeitem belonging to the treecell
Dim ti As TreeItem = joIP.RunMethod("getTreeItem", Null)
'Check if treeitem is initialized and a number - f.e. if root is visible then not a number
If ti.IsInitialized And IsNumber(ti.Text) Then
'Set the cell color depending threshold
If ti.Text < threshold Then
CSSUtils.SetBackgroundColor(l.Get(i), fx.Colors.green)
Else
CSSUtils.SetBackgroundColor(l.Get(i), fx.Colors.red)
End If
End If
Next
End Sub