B4J Code Snippet Generate Members for SceneBuilder (workaround)


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 "GenerateMembersFMXL.exe"
  2. Copy "GenerateMembersFMXL.exe" somewhere, in my case I put it in AdditionalLibraries.
  3. in B4J IDE, right click on a fxml file:
    1. b4j_GenMembers1.PNG
  4. Paste the full pathto "GenerateMembersFMXL.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:
$f = @ScriptDir & "..\..\..\Files\myfile.fxml"

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

$hwnd = FileOpen($f, 0)
$s = FileRead($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
        $index +=1
    ConsoleWrite("Result String: " & $result & @CRLF)


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

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


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