B4J Code Snippet Generate Members for SceneBuilder (workaround)

Hi,

This is a workaround to kind of restore the old "Generate Members" behavior, for UI generated with JavaFX Scene Builder. I understand that using Scene Builder is not recommended anymore, but this will be useful for people like me who are still supporting programs created using SB.

I created an AUTOIT script that help with that. Attached to this post are the original AutoIt Script, and the compiled exe file.
  1. Download the attached Script.zip, extract "GenerateMembersFXML.exe"
  2. Copy "GenerateMembersFXML.exe" somewhere, in my case I put it in AdditionalLibraries.
  3. in B4J IDE, right click on a fxml file and select "Configure External Editors":
    1. b4j_GenMembers1.PNG
  4. Paste the full path to "GenerateMembersFXML.exe", then press "Ok"
    1. b4j_GenMembers2.PNG
  5. Now right click on the fxml again, select "Open with GenerateMembersFXML". This will copy the variables to your ClipBoard
    1. b4j_GenMembers3.PNG
  6. Paste the Variables to B4J (CTRL+V):
    1. b4j_GenMembers4.PNG

Note that it's not a complete replacement to the old behavior, but it's enough to save time.

The compiled script shared here is free of virus, but you can compile it by yourself using AutoIt if you like. Here is the script below. The source code is also included in the .zip file:
B4X:
$f = @ScriptDir & "..\..\..\Files\myfile.fxml"

if $cmdline[0] > 0 then $f = $cmdline[1]

$hwnd = FileOpen($f, 0)
$s = FileRead($hwnd)
FileClose($hwnd)

Local $sID = StringRegExp($s, '(\w+)\s+id="([^"]+)"', 3) ; Extracting ID using regex

If IsArray($sID) Then

    ConsoleWrite("Extracted IDs: ")
    Local $result = ""
    local $index = 0
    For $i = 0 To UBound($sID) - 1
        if Mod($index, 2) = 0 then
            If $result <> "" then $result &= @CRLF
            $result &= "Private " & $sID[$i + 1] & " As " & $sID[$i] ; Append each ID to the result string
        EndIf
        $index +=1
    Next
    ConsoleWrite(@CRLF)
    ConsoleWrite("Result String: " & $result & @CRLF)

    ClipPut($result)

    if ClipGet() = $result Then
        MsgBox(1, "B4J", "Variables copied to clipboard", 1)
    Else
        MsgBox(1, "B4J", "Copy didn't work", 1)
    EndIf

Else
    ConsoleWrite("ID not found!" & @CRLF)
EndIf
 

Attachments

  • Scripts.zip
    323.4 KB · Views: 167
Last edited:

jmon

Well-Known Member
Licensed User
Longtime User
Hello also for the B4J 10 version?
Yes, but understand that it works only with FXML files created with Javafx Scene Builder. Most people are now using the internal designer and shouldn't need this script.
 

Swissmade

Well-Known Member
Licensed User
Longtime User
Nice but also a wish to get a converter Javafx Scene Builder to internal designer if possible.
 
Top