Description
The following code fails with an exception: Cannot cast object 'Red' with class 'java.lang.String' to class 'java.awt.Color' instead of showing the frame. The initial update of the property should insure that the validator and converter are called.
All synthetic binding properties should be checked for such errors as well.
import java.awt.Color import groovy.swing.SwingBuilder sb = new SwingBuilder() sb.frame(pack:true, show:true) { panel { def colors = [Red: Color.RED, Green: Color.GREEN, Blue: Color.BLUE] label('Look at my colors!', id:'lbl') comboBox(items:colors.collect {k, v-> k}, id:'combo', selectedItem: bind (target:lbl, 'foreground', converter: {v -> println v; colors[v]})) } }