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

[SwingBuilder] ListFactory does not use custom JList instance if items: is specified

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8.8, 2.0.5
    • 2.0.6
    • Swing
    • None

    Description

      From the Griffon User list ->

      Hi everyone. I feel like the answer is staring me in the face on this one but I can't figure out what I'm doing wrong.

      I have an object that extends JList:

      class MyList extends JList {
           
           public MyList(){
               super()
           }
      
           ... custom methods ...
      }
      

      and I'm using it in my view as such:

      list(new MyList(), id:'listId', items:["item 1","item 2","etc"], valueChanged:controller.listSelectionChangedAction)
      

      Then in my controller I have:

      def listSelectionChangedAction = { evt ->
           def list = (MyList)evt.source
           ... do stuff with list ...
      }
      

      But I'm getting an error for the type casting:

      2012-11-27 19:34:52,434 [pool-2-thread-2] ERROR griffon.util.GriffonExceptionHandler - Uncaught Exception
      org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'javax.swing.JList[listId,0,0,256x136,alignmentX=0.0,alignmentY=0.0,border=,flags=50331944,maximumSize=,minimumSize=,preferredSize=,fixedCellHeight=-1,fixedCellWidth=-1,horizontalScrollIncrement=-1,selectionBackground=com.apple.laf.AquaImageFactory$SystemColorProxy[r=42,g=91,b=213],selectionForeground=com.apple.laf.AquaImageFactory$SystemColorProxy[r=255,g=255,b=255],visibleRowCount=8,layoutOrientation=0]' with class 'javax.swing.JList' to class 'com.myproject.MyList'
      

      Attempts to access the custom methods of my list class without the type casting also produce an error. Anyone know what's wrong with this? Thanks in advance.

      Attachments

        Activity

          People

            aalmiray Andres Almiray
            aalmiray Andres Almiray
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: