B4J Question Get panel background color

micro

Well-Known Member
Licensed User
Longtime User
Hi to all
there is an easy way how to get a background color of a panel?
(I change the background color in certain situations)
I do not want to use several variables to check the status of the bachground color.
Thanks
 

Roycefer

Well-Known Member
Licensed User
Longtime User
B4J doesn't use Panels, it uses Panes. If you're trying to change the background color of a JavaFX Pane in B4J, that is done through the Pane.Style property:
B4X:
Dim p as Pane
p.Initialize("p")
p.Style = "-fx-background-color:chartreuse"   'sets the Pane's background color with a CSS String
Log("p's background color: " & Regex.Split(":", p.Style)(1))  'gets the Pane's CSS String, extracts the color and Logs it
Be warned, though, that this method is brittle and it's more flexible to store the desired color value in a variable that you can plug into a much larger CSS template String as you desire. The CSS Strings can do much more than just set background colors. You'll have to do a little more work now, but you'll save yourself a lot of work in the future if you decide to style other aspects of the Pane.
 
Upvote 0
Top