B4J Question How to set TreeViewItem colour and or Font

Daestrum

Expert
Licensed User
Longtime User
Simple example, probably better ways to do it (cell factory etc)
B4X:
Dim treev As TreeView
Dim titem As TreeItem
treev.Initialize("")
titem.Initialize("","one")
treev.Root.Children.Add(titem)
MainForm.RootPane.AddNode(treev,0,0,-1,-1)
Dim titem2 As JavaObject ' can't use b4j treeitem as we want a label not string
Dim lab As Label
lab.Initialize("")
lab.Text = "two"
If lab.Text = "two" Then
CSSUtils.SetStyleProperty(lab,"-fx-text-fill","red")
CSSUtils.SetStyleProperty(lab,"-fx-font-style","italic")
Else
CSSUtils.SetStyleProperty(lab,"-fx-text-fill","black")
CSSUtils.SetStyleProperty(lab,"-fx-font-style","normal")
End If
titem2.InitializeNewInstance("javafx.scene.control.TreeItem",Array(lab))
titem.Children.Add(titem2)
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
I think you will get an error as CSSUtils cant change style of String.
 
Upvote 0
Top