B4J Question pane background color problem

tufanv

Expert
Licensed User
Longtime User
Hello,

In one of my apps I am using :

B4X:
Sub mypairsdoldur
    If listmypairs.IsInitialized=True Then
        Dim p As Pane
        Dim sv As ScrollPane
        sv.Initialize("sv")
        p.Initialize("p")
       
        p = sv.InnerNode
        p.RemoveAllNodes

   

        For i=0 To listmypairs.Size-1
       

            lblpair(i).Initialize("lblcoin")
            lbldegisim(i).Initialize("lbldegisim")
            lblprice(i).Initialize("lblprice")
            lbllowest(i).Initialize("lbllowest")
            lblhighest(i).Initialize("lblhighest")
            panepair(i).Initialize("panepair")
           
           
            If i=0 Or i=2 Or i=4 Or i=6 Or i=8 Or i=10 Or i=12 Or i=14 Or i=16 Or i=18 Or i=20 Then
                panepair(i).Style="-fx-background-color:#F08080"
           
            Else
                panepair(i).Style="-fx-background-color:#FF0000"
               
            End If
            Log(panepair(i).Style)

            lblpair(i).Text=listmypairs.Get(i)
            lblpair(i).Alignment="CENTER_LEFT"
            lblpair(i).TextColor=fx.Colors.white

            p.AddNode(panepair(i),0,i*50,0,50)
            panepair(i).AddNode(lblpair(i),2,0,100,50)
   
           
       
        Next

        scrollana.InnerNode=p

       
    Else
   
    End If
End Sub


and this doesnt change the color of the pane

in another app I am using :

B4X:
Sub mycoinsdoldur
   

   
   
    If listmycoins.IsInitialized=True Then
        Dim p As Pane
        Dim sv As ScrollPane
        sv.Initialize("sv")
        p.Initialize("p")
       
        p = sv.InnerNode
        p.RemoveAllNodes
   

        For i=0 To listmycoins.Size-1
       

            lblcoin(i).Initialize("lblcoin")
            renk(i).Initialize("renk")
            lbldel(i).Initialize("lbldel")
       
            lbldel(i).Font=fx.CreateFontAwesome(15)
            lbldel(i).TextColor=fx.Colors.white
            lbldel(i).Text=""
            lbldel(i).Tag=i
       
            txtadet(i).Initialize("txtadet")
            '        txtadet(i).Text="0.0"
            txtadet(i).Style="-fx-text-inner-color:" &WHITESMOKE & ";-fx-alignment: CENTER"
            '            txtadet(i).Style="-fx-alignment: CENTER"
            txtadet(i).Tag=i
           
            tutar(i).Initialize("tutar")
            tutar(i).Alignment="CENTER"
            tutar(i).Font=fx.CreateFont("Verdana","11",True,False)
            tutar(i).TextColor=fx.Colors.RGB(150,255,173)
            '            tutar(i).Text="$ 0"
       
            lblcoin(i).Text=listmycoins.Get(i)
            lblcoin(i).Alignment="CENTER_LEFT"
            If i=0 Or i=8 Or i=16 Or i= 24 Or i=32 Then
                renk(i).Style="-fx-background-color:" &GOLD
            else if i=1 Or i=9 Or i=17 Or i=25 Or i=33 Then
                renk(i).Style="-fx-background-color:" &CRIMSON
            else if i=2 Or i=10 Or i=18 Or i= 26 Or i=34  Then
                renk(i).Style="-fx-background-color:" &AQUA
            else if i=3 Or i=11 Or i=19 Or i= 27 Or i=36 Then
                renk(i).Style="-fx-background-color:" &GREENYELLOW
            else if i=4 Or i=12 Or i=20 Or i= 28 Or i=37 Then
                renk(i).Style="-fx-background-color:" &HONEYDEW
            else if i=5 Or i=13 Or i=21 Or i= 29 Or i=38 Then
                renk(i).Style="-fx-background-color:" &GOLDENROD
            else if i=6 Or i=14 Or i=22 Or i= 30 Or i=39 Then
                renk(i).Style="-fx-background-color:" &LIME
            else if i=7 Or i=15 Or i=23 Or i= 31 Or i=40 Then
                renk(i).Style="-fx-background-color:" &LIGHTSEAGREEN
            Else
                renk(i).Style="-fx-background-color:" &WHITE
            End If
       
            If kvsmycoins.ContainsKey(lblcoin(i).Text) Then
       
                txtadet(i).text= kvsmycoins.Get(lblcoin(i).text)
                txtadet(i).Text=txtadet(i).Text.Replace(",",".")
            Else
                txtadet(i).text="0.0"
            End If
           
   

   


            p.AddNode(renk(i),0,i*40,10,30)
            p.AddNode(lblcoin(i),15,renk(i).top,70,28)
            p.AddNode(lbldel(i),70,renk(i).top,70,28)
           
            p.AddNode(txtadet(i),105,renk(i).top,70,28)
            p.AddNode(tutar(i),scrollcoins.Width-110,renk(i).top,100,28)
           
       
        Next

        scrollcoins.InnerNode=p

       
    Else
   
    End If

End Sub

and this works without a problem. The code is identical , why one of them is working but other one is not , I am spending my last 2 hours to figure this out but i cant.
Any help would be appreciated.
 

tufanv

Expert
Licensed User
Longtime User
It is a mistake to set the Style property directly. You should instead set the attributes with CSSUtils.
I have switched to cssutils. That is the code copied from an old project for testing only. Thanks !
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…