Public Sub NodeSetImage(n As Node, ImageDir As String, ImageFileName As String, Width As Int, Height As Int, ContentDisplay As String)
'Check that path and filename are valid:
If ImageDir = "" Or ImageFileName = "" Then Return
'Set the button image:
Dim iv As ImageView
Dim nJo As JavaObject = n
iv = nJo.RunMethod("getGraphic", Null)
If iv.IsInitialized Then
iv.SetImage(fx.LoadImageSample(ImageDir, ImageFileName, iv.Width, iv.Height))
Else
iv.Initialize("")
If Width > -1 Then
iv.Width = Width
End If
If Height > -1 Then
iv.Height = Height
End If
iv.SetImage(fx.LoadImageSample(ImageDir, ImageFileName, iv.Width, iv.Height))
nJo.RunMethod("setGraphic", Array(iv))
Dim cd As JavaObject
cd.InitializeStatic("javafx.scene.control.ContentDisplay")
nJo.RunMethod("setContentDisplay", Array(cd.RunMethod("valueOf", Array(ContentDisplay))))
End If
End Sub