• 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

Applet Code Error

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I try to run DonnaApplet, the appletviewer screen comes up and I'm able to feed in the name and numbers but when I click Submit Scores I get this error message:
A:\>appletviewer DonnaApplet.html
Exception occurred during event dispatching:
java.lang.NumberFormatException:
at java.lang.Integer.parseInt(Compiled Code)
at java.lang.Integer.parseInt(Integer.java:458)
at DonnaApplet.actionPerformed(DonnaApplet.java:126)
at java.awt.AWTEventMulticaster.actionPerformed(AWTEventMulticaster.java
:351)
at java.awt.Button.processActionEvent(Button.java:308)
at java.awt.Button.processEvent(Button.java:281)
at java.awt.Component.dispatchEventImpl(Compiled Code)
at java.awt.Component.dispatchEvent(Compiled Code)
at java.awt.EventQueue.dispatchEvent(Compiled Code)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:68)
Here's my code:

Thanks
Linda

[This message has been edited by Cindy Glass (edited December 03, 2001).]
 
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In your init() method you do this line twice:
submitButton.addActionListener(this);
The second one should be
displayButton.addActionListener(this);
You still need to put error checking in for the rank textfield in case a non number is entered in or nothing at all.
What is currently happening is the action listers actionPerformed() is being fired twice for every click. The second time in the textfield contains nothing so you get the exception. Which is why you need to put in error checking.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic