B4J Question Button with Image

BPak

Active Member
Licensed User
Longtime User
Is there a way to put image into a button?
I wish to use buttons with the Triangle (arrow <) for database navigation.
 

rwblinn

Well-Known Member
Licensed User
Longtime User
Hi,

another option is to use CSS via the JavaFX Scene Builder.
Drag an ImageView on top of a Button and it will automatically be set as a graphic for the button.
Then select the ImageView and type the URL of the image into the ImageView's image field in the
Scene Builder properties pane.
To select an image file from the DirAssets folder, select the file accordingly in the
ImageView Properties > Image.
After selection, the URL looks like (Example): @helpimage.png

The FXML contains as a result (Example):
B4X:
<Button id="buttonHelp" font="$x4" layoutX="20.0" layoutY="20.0" mnemonicParsing="false" text="Help">
  <graphic>
  <ImageView pickOnBounds="true" preserveRatio="true">
  <image>
  <Image url="@helpimage.png" />
  </image>
  </ImageView>
  </graphic>
</Button>
 
Upvote 0
Top