Details
Description
The following code throws an exception
import groovy.swing.SwingBuilder def model = [word:""] as ObservableMap new SwingBuilder().edt { frame( title: "BindTest", pack: true, visible: true ) { tabbedPane { panel( title: "a") { borderLayout() textField( id: 'wordValue', columns: 20) button( "Click me", actionPerformed: { println model.word }, constraints: context.SOUTH) } bean( model, word: bind{ wordValue.text } ) } } }
Exception thrown: No signature of method: java.util.ArrayList.containsKey() is applicable for argument types: (java.lang.String) values:
{value}groovy.lang.MissingMethodException: No signature of method: java.util.ArrayList.containsKey() is applicable for argument types: (java.lang.String) values: {value}
at ConsoleScript3$_run_closure1_closure2_closure3.doCall(ConsoleScript3:15)
at ConsoleScript3$_run_closure1_closure2_closure3.doCall(ConsoleScript3)
at ConsoleScript3$_run_closure1_closure2.doCall(ConsoleScript3:7)
at ConsoleScript3$_run_closure1_closure2.doCall(ConsoleScript3)
at ConsoleScript3$_run_closure1.doCall(ConsoleScript3:6)
That is because tabbedPane expects all its children to supply tab friendly properties, like title:, which in this case bean() does not provide. A workaround is to place bean() in another context, but the error and the reason why it happens is not intuitive. TabbedPane could be smarter and filter out those child nodes that do not conform to the rules, for example those that do not return a Component.
Activity
| Field | Original Value | New Value |
|---|---|---|
| Fix Version/s | 1.6 [ 13832 ] | |
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Resolution | Fixed [ 1 ] |
| Assignee | Danno Ferrin [ shemnon ] |
| Status | Resolved [ 5 ] | Closed [ 6 ] |
The issue was actually a collision between bind and tabbed pane. Both were using the instance of the node object a key in the context. While we could limit what types were being keyd, the long term (and implemented) solution is to modify the technique used to access the keys in the build context.