Sub AppStart (Form1 As Form, Args() As String)
...
'Define the button and add to the rootpane of the mainform
Dim btn As Button
btn.Initialize("btn")
btn.Tag = "This is my ImageButton"
MainForm.RootPane.AddNode(btn, 20,20,50, 50)
'Create the imageview and add to the button
Dim iv As ImageView
iv.Initialize("")
'Ensure the image myimage.png is added to the files tab and stored in the files folder
iv.SetImage(fx.LoadImage(File.DirAssets, "myimage.png"))
ButtonSetGraphic(btn, iv)
End Sub
'Add the icon using API call
Sub ButtonSetGraphic(btn As Button, Graphic As Node)
Dim jo As JavaObject = btn
jo.RunMethod("setGraphic", Array(Graphic))
End Sub