B4J Question Background color

LucaMs

Expert
Licensed User
Longtime User
Is there a direct way to set the background color of "views"?
(or a better solution compared to the following, which I do not like "too much")

I wrote and suggested these two routines (and you could suggest better names for them :)) I'm not devoting time to b4j, only to a server without GUI, then I'm not an expert, absolutely.

B4X:
Button1.Style = SetStyleBackground(fx.Colors.Red)
...

' "SetStyle" because I thought to pass the "view"
Sub SetStyleBackground(Color As Object) As String
    Return "-fx-background-color:" & StyleColorString(Color)
End Sub

Sub StyleColorString(FXColor As String) As String
    Return "#" & FXColor.SubString(2) & ";"
End Sub


[Also, probably there is a method to pass "views" as parameters and...]
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
Is this correct?
B4X:
' Sets the background color of a Node
' Color: pass a "JFX.Color" object
Sub SetBGColor(MyNode As Node, Color As Object)
    Dim strColor As String = Color
    MyNode.Style = "-fx-background-color:" & "#" & strColor.SubString(2) & ";"
End Sub
 
Last edited:
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Last question (I should open a new thread, I know, but I need only a "yes" or "not"):

Can I get all the properties of a Node set by Designer and saved in a CSS file? (if so, I could write a list of MyNode.Style lines).


P.S. I fear there are no CSS files created by Designer, but it is incorporated some way in the layout file.
 
Upvote 0
Top