• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ItemListener: Exception in thread "AWT-EventQueue-1"

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm getting following errors when trying to implement ItemListener:

Exception in thread "AWT-EventQueue-1" java.lang.ClassCastException: java.awt.Checkbox cannot be cast to java.awt.Choice
at SurveyApplet.itemStateChanged(SurveyApplet.java:68)


Please, advise:

 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you get this sort of problem it's best to read the API docs for the class to see what type the method actually returns. The docs say the getItemSelectable() method returns an object of type ItemSelectable (which in your case is the JCheckbox) but you are trying to cast it to a type Choice, which it isn't.
reply
    Bookmark Topic Watch Topic
  • New Topic