Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6529887

ClassCastException in AbstractButton.java

    XMLWordPrintable

    Details

      Description

      FULL PRODUCT VERSION :
      java version "1.6.0"
      Java(TM) SE Runtime Environment (build 1.6.0-b105)
      Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)


      ADDITIONAL OS VERSION INFORMATION :
      Linux beowulf.netforensics.com 2.6.18-1.2257.fc5 #1 Fri Dec 15 16:06:24 EST 2006 i686 i686 i386 GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      JXTable sub-classes from JTable and provides a nice popup of all the columns in the JTable. Unfortunately, when I set the HeaderValue for any of the TableColumns to anything other than "String", I get a ClassCastException from the bowels of Swing:

      Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: com.netforensics.ui.views.enums.Columns cannot be cast to java.lang.String
      at javax.swing.AbstractButton.setActionCommandFromAction(AbstractButton.java:1274)

      Looking at the source, I see that this method casts Action.getValue() to a String - a bug, since getValue() is expected to return an Object, not a String. The simple fix is to use "toString()".


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      See above - it's a simple fix.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Action.getValue(), according to the documentation, returns an Object. Therefore, AbstractButton cannot simply cast it to a String.
      ACTUAL -
      ClassCastException as per above description.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: com.netforensics.ui.views.enums.Columns cannot be cast to java.lang.String
      at javax.swing.AbstractButton.setActionCommandFromAction(AbstractButton.java:1274)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      none needed - simply change the code to call toString() rather than casting it to a String.
      ---------- END SOURCE ----------

        Attachments

          Activity

            People

            Assignee:
            alexp Alexander Potochkin (Inactive)
            Reporter:
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: