B4J Question Using a transparent image on a button

dieterp

Active Member
Licensed User
Longtime User
I have a transparent .png file that I use for an image on a button (An undo arrow). In B4A and B4I, the image will make the button transparent too. When I do the same in B4J though I get a greyish color background for the image. Is it possible to get the button to also become transparent in B4J?
 

dieterp

Active Member
Licensed User
Longtime User
I have tried playing around with the alpha. That makes the whole button eventually disappear (alpha = 0) including the image that is on the button. Setting alpha = 0.5 just gives me a faded button but the background is still there
 
Upvote 0

dieterp

Active Member
Licensed User
Longtime User
Thanks Erel. Is the only solution to set it up through code and not the designer? I have quite a lot of buttons that use transparent images in the app
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Try setting the Buttons background color to transparent in the designer extra-css field : -fx-background-color: 0000;

or you can use CSSUtils to do it in code.
 
Upvote 0

dieterp

Active Member
Licensed User
Longtime User
Just one question on the solution above; I get a warning message (Listed below) in the logs. Is this something I should be concerned about or can it be ignored?

Nov 27, 2017 10:35:58 AM javafx.scene.CssStyleHelper calculateValue
WARNING: Caught 'java.lang.ClassCastException: java.lang.Double cannot be cast to javafx.scene.paint.Paint' while converting value for '-fx-background-color' from inline style on Button@ff46c6[styleClass=button]''
 
Upvote 0
Top