Generated Object

An internal class that currently should not be relied on.

Attributes

Content

bind accepts no content

Usage

bind can be used as a stand alone element or as a value for any attribute of any object.

When used as an attribute value the target and targetProperty values implicitly become the current object being constructed and the property being written to.

Until the external API is finalized, it is not recommended to use the object returned from bind

Examples

Example binding one property to another:

swing.frame() {
  panel {
    textField('Change Me!', id:'tf')
    button(text: bind(source:tf, sourceProperty:'text'))
  }
}

Example when triggering on a particular event with a value closure

swing.frame() {
  panel {
    textField('Change Me!', id:'tf')
    button(text: bind(source:tf.document, sourceEvent:'undoableEditHappened', 
      sourceValue:{System.currentTimeMillis()}))
  }
}

Note that the source value can get any arbitrary value.

Example with validator and converter:

swing.frame() {
  panel
   {
    textField('Change Me!', id:'tf')
    button(text: bind(source:tf, sourceProperty:'text',
      validator: { tf.text.length() >= 1}, converter: { it.toLowerCase() } ))
   }
}

In this example the validator prevents the button text from having less than 1 char and the converter makes the button text all lowercase.

Note: Tested on Groovy 1.5.1