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

ComboBox#selectedItem synthetic property ignores converter on first update

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Cannot Reproduce
    • 1.6
    • 1.6.2
    • Swing
    • None

    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]}))
      }
      }
      

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: