Ola
I am getting an error on the AwtImageToImage sub. with normal java this works.
Thanks.
B4X:
Sub GetFileIcon(Dir As String, FileName As String) As Image
Dim jo As JavaObject
Dim JavaFile As JavaObject
Dim icon As JavaObject
JavaFile.InitializeNewInstance("java.io.File", Array(File.Combine(Dir, FileName)))
If GetSystemProperty("os.name", "").ToLowerCase.Contains("win") Then
icon = jo.InitializeStatic("sun.awt.shell.ShellFolder").RunMethodJO("getShellFolder", Array(JavaFile)).RunMethod("getIcon", Array(True))
Else
icon = jo.InitializeStatic("sun.awt.shell.ShellFolder").RunMethodJO( _
"getShellFolder", Array(JavaFile)).RunMethod("getIcon", Array(True))
Dim fc As JavaObject
fc.InitializeNewInstance("javax.swing.JFileChooser", Null)
Dim icon As JavaObject = fc.RunMethodJO("getUI", Null).RunMethodJO("getFileView", Array(fc)).RunMethod("getIcon", Array(JavaFile))
Dim AquaIcon As JavaObject
AquaIcon.InitializeStatic("com.apple.laf.AquaIcon")
icon = AquaIcon.RunMethod("getImageForIcon", Array(icon))
End If
Return AwtImageToImage(icon)
End Sub
Private Sub AwtImageToImage(img As JavaObject) As Image
Log(GetType(img))
Dim jo As JavaObject
Return jo.InitializeStatic("javafx.embed.swing.SwingFXUtils").RunMethod("toFXImage", Array(img, Null))
End Sub
I am getting an error on the AwtImageToImage sub. with normal java this works.
Thanks.