B4J Question Get panel background color

Discussion in 'B4J Questions' started by micro, Jul 18, 2015.

  1. micro

    micro Well-Known Member Licensed 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.
  2. Roycefer

    Roycefer Well-Known Member Licensed 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:
    Dim p as Pane
    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.
  3. micro

    micro Well-Known Member Licensed User

    Ok, Thanks (For panel i meant pane).
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice