The itemStateChanged method

From: Tim Mierzejewski (timmierz_at_yahoo.com)
Date: 06/21/04


Date: Mon, 21 Jun 2004 14:58:33 GMT

I have a List and a Choice on an applet and I want a TextField below them to
display the selected text of each one. Everything's good until runtime when
I actually select one, I get errors (below). There is an ItemListener on
both the List and the Choice. First, here is my itemStateChanged method:

public void itemStateChanged(ItemEvent ie)
{

Choice selBrgd = (Choice)ie.getItemSelectable();

List selType = (List)ie.getItemSelectable();

tfResult.setText("A " + selBrgd.getSelectedItem() + " " +
selType.getSelectedItem());

}

And here are the errors:

java.lang.ClassCastException
at JavaTest.Chapter13.CardChoice.itemStateChanged(CardChoice.java:51)
at java.awt.Choice.processItemEvent(Unknown Source)
at java.awt.Choice.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Thanks,
Tim



Relevant Pages

  • Re: Shell Image View Control in System32
    ... the "Choose Program" applet still will not display ... While still in Windows Explorer, ... a program other than the correct one for the extension, ... The "Choose Program" applet does not display when I right click my mouse ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: need to extract data from an html page into a csv file (txt)
    ... >A page is displayed in html which looks like a spreadsheet. ... >can export all the data displayed on this html page into a csv file ... You could do the display with a JTable Applet with a local cache of ... You could also have the signed Applet or JAWS Applet/application ...
    (comp.lang.java.programmer)
  • Re: web browser display
    ... >If I want to modify the displayed screen appearance, ... >Do I write a Java applet to run inside a web browser to do that? ... The conceptually simplest is with a JWS or a signed Applet. ... the browser to display it. ...
    (comp.lang.java.programmer)
  • Re: Help with Threads (wait and notify)
    ... > When the user clicks on this button i want my applet to display the second ... public class Test extends Applet { ... http://uio.dev.java.net Unified I/O for Java ...
    (comp.lang.java.gui)
  • Problems with applet for displaying desktop apps output
    ... When the system first wants to display output it ... fires up the web browser with an html ... socket for the applet to display. ...
    (comp.lang.java.programmer)