B4X:
MainForm.SetFormStyle("UTILITY")
B4X:
Private Sub btnLoadFile_Click
firmware = Array As Byte() ' Resets to an empty array (length 0)
jframe.InitializeNewInstance("javax.swing.JFrame",Array(""))
openFileDialog
End Sub
Private Sub openFileDialog
Dim fileChooser As JavaObject
fileChooser.InitializeNewInstance("javax.swing.JFileChooser", Array(Null))
Dim result As Int = fileChooser.RunMethod("showOpenDialog", Array(jframe))
If result = fileChooser.GetField("APPROVE_OPTION") Then
Dim selectedFile As JavaObject = fileChooser.RunMethod("getSelectedFile", Null)
Dim filePath As String = selectedFile.RunMethod("getPath", Null)
LogMessage("Status", "Selected file Path: " & filePath)
Dim FileName As String = fileChooser.RunMethodJO("getSelectedFile",Null).RunMethod("getName",Null)
LogMessage("Status", $"Selected file name: ${FileName}"$)
' Process and convert to binary the selected file
firmware = ConvertHexIntelToBinaryRange(filePath, START_ADDR_FLASH)
Else
LogMessage("Status", "No file selected.")
End If
' Must do or app will not exit. Caused by fileChooser
If jframe.IsInitialized Then
jframe.RunMethod("dispose", Null)
End If
End Sub
Can we make this code work in UTILITY Style?