Lemur window definitions via groovy

I started working on a groovy DSL to specify lemur windows.


Groovy definition:

import com.simsilica.lemur.Axis
import com.simsilica.lemur.FillMode
import com.simsilica.lemur.component.SpringGridLayout

window("testWindow") {

    def textLabel = label("testLabel", "text") {

    container("testContainer") {

        setLayout(new SpringGridLayout(Axis.X, Axis.Y, FillMode.Even, FillMode.Even))

        label("testLabel2", "Label2") {

        label("testLabel3", "Label3") {

        button("testButton", "Direct action") {
            onClick({ println "CLICK" })

        button("testButton2", "Delegate") {
            onClick({ callDelegate("buttonClicked") })

    action("TestAction") {
        println "Hello"

    action("ChangeText") { newTxt ->
        textLabel.text = newTxt


Java binding:

Window w = windowManager.getWindow("testWindow"); //Get the window
w.setDelegate("buttonClicked", () -> { //Add a delegate that is called when the testButton2 is clicked -> groovy:      
   //onClick({ callDelegate("buttonClicked") })
    System.out.println("Delegate called!");
    w.executeAction("ChangeText", "New label text"); //Execute a change in the gui -> groovy:
    /*action("ChangeText") { newTxt ->
        textLabel.text = newTxt
w.show(); //Aattach the window to the guiNode

I’m not very far yet (actually I used all implemented features in this example), but I’d like to hear opinions on this. Would this be useful for other people too? Has someone ideas to implement things more concise or cleaner in the DSL?


I’ve played with this a few times and still don’t have anything I like (yet).

I either can’t come up with an elegant way to set child constraints (it looks very un-DSL like) or I end up having to add a new method for every type of element… which means users are screwed if they want to add their own. Builders haven’t really helped here, either.