groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Johnson <>
Subject how can SwingBuilder work?
Date Wed, 08 Apr 2015 00:05:34 GMT
I'm working a program that was mostly written by someone else.

Some of the code I didn't write has things like

 public Object windowSpec() {

    return {

        def windowFrame = frame(attributes+[pack: true,
defaultCloseOperation: windowCloseAction]) {


            widget([widget:,id: 'content'])






which gets called from a method that is sort of like

protected buildView() {

    builder.edt {

       view =



How can this work?   In particular, when windowSpec calls methods defined
by the SwingBuilder such as frame() and menuBar(), why are those considered
methods on the SwingBuilder and not on the class that contains the class
that contains this code?

There are a bunch of subclasses of the class with this code that works
correctly, but one where it doesn't, and I'm trying to figure out why.
But then I realized that I don't understand how it works at all.   Does the
method build() change the closure so that it will look in the SwingBuilder
for those methods?

-Ralph Johnson

View raw message