Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


Here's an example:

Code Block
def f = framesizeframe(size:[300,300], text:'My Window') {
    labelboundslabel(bounds:[10,10,290,30], text:'Save changes')
    panelboundspanel(bounds:[10,40,290,290]) {
        buttontextbutton(text:'OK', action:{ save close })
        buttontextbutton(text:'Cancel', action:{ close })

The above invokes a number of methods on the owner class using named-parameter passing syntax. Then the button method would create JButton etc. The { } is used to define a closure which adds its content to the newly created node. Also notice that the action parameter is passed as a closure - which is ideal for working with UI centric listeners etc.

Note that within the 'markup' you can embed normal expressions - i.e. this markup syntax is a normal part of the Groovy language. e.g.

Code Block
def f = frametextframe(text: calculateFieldNamefoo, 1234){

    // lets iterate through some map
    map = [1:"hello", 2:"there"]

    for e in map {