groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Johnson <john...@cs.uiuc.edu>
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]) {

            menuBar(this.menuBarSpec)

            widget([widget: builder.build(contentViewSpec),id: 'content'])

         }

        windowFrame.addWindowListener(this)

        windowFrame

    }

}


which gets called from a method that is sort of like


protected buildView() {

    builder.edt {

       view = builder.build(this.windowSpec())

    }

}


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

Mime
View raw message