I have tried this code which works fine on PC. However it generates an "run-time initialization" error on Mac. See the screenshot. I will install JDK v9.0.4 on my virtual Mac to see if that helps.
UPDATE:
See Erel's post #5 for the solution.
In case you want to set up vmWare (Mac emulator for PC)
B4J caller code
Result on Mac
Java version (MacOSX El Capitan)
Provided is a drag and drop example. Source code and JAR file.
UPDATE:
See Erel's post #5 for the solution.
In case you want to set up vmWare (Mac emulator for PC)
You can confirm this yourself by settings up an account at vmWare (go here) and download vmWare v15 which is a really good Mac emulator. Then you can set it up with an El capitan vmware image(AMD) or Mojave (demands an Intel CPU). Search Youtube to find out how it's done depending which system you've got. The GetFileIcon code works on Windows but needs to be initialized on Mac. Please prove the final solution here once you have confirmed that it works on a Mac emulator or real hardware.
From original post
ImageView1.SetImage(GetFileIcon("C:\Program Files (x86)\Anywhere Software\B4J", "B4J.exe"))
B4X:
Sub GetFileIcon(Dir As String, FileName As String) As Image
Dim jo As JavaObject
Dim JavaFile As JavaObject
JavaFile.InitializeNewInstance("java.io.File", Array(File.Combine(Dir, FileName)))
Dim icon As JavaObject = jo.InitializeStatic("sun.awt.shell.ShellFolder").RunMethodJO( _
"getShellFolder", Array(JavaFile)).RunMethod("getIcon", Array(True))
Return AwtImageToImage(icon)
End Sub
Private Sub AwtImageToImage(img As JavaObject) As Image
Dim jo As JavaObject
Return jo.InitializeStatic("javafx.embed.swing.SwingFXUtils").RunMethod("toFXImage", Array(img, Null))
End Sub
B4J caller code
Result on Mac
Java version (MacOSX El Capitan)
Provided is a drag and drop example. Source code and JAR file.
Attachments
Last edited: