Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-3288

SwingBuilder.tabbedPane imposes strict restrictions on its children

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6-rc-1
    • 1.6-rc-2
    • Swing
    • None

    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.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            shemnon Daniel Ferrin
            aalmiray Andres Almiray
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment