B4J Question B4J Button Images - Problems

rodmcm

Active Member
Licensed User
This test program is based on a snippet I found on this site, but gives some unusual results. Can someone please correct this or link me to a foolproof method to put images on buttons etc in B4J
 

Attachments

  • B4J Buttons_Test.zip
    3.5 KB · Views: 85

stevel05

Expert
Licensed User
Longtime User
That is the expected behaviour. the set graphic method on a node adds the graphic within the target node, thereby stretching the target node to allow it to fit.

If you want to change the background image of the button, use the CSSUtils library.

B4X:
Sub ButtonBOTTOM(BTN As Button)
    CSSUtils.SetBackgroundImage(BTN,File.DirAssets,"ButtonBot.PNG")
End Sub


Sub ButtonTOP (BTN As Button)
    CSSUtils.SetBackgroundImage(BTN,File.DirAssets,"ButtonTop.PNG")
End Sub
 
Last edited:
Upvote 0

stevel05

Expert
Licensed User
Longtime User
From the Javafx javadoc. Search Google for javafx 8 javadoc. Or 11 if you want that. There is a wealth of information in there. Or search for a specific control. "Javafx 8 Node" for example.
 
Upvote 0
Top