This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Applets and the fly likes ItemListener: Exception in thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "ItemListener: Exception in thread "AWT-EventQueue-1"" Watch "ItemListener: Exception in thread "AWT-EventQueue-1"" New topic
Author

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

Natalie Green
Greenhorn

Joined: Dec 15, 2013
Posts: 4
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:

Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 1950
    
  28
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ItemListener: Exception in thread "AWT-EventQueue-1"
 
Similar Threads
AWT Applet Instantiation Error
Need help with editing variables.
placing images in applets
Instantiation Error in AWT Applet code
ItemListener: checkbox component