• 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

Exceptions

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In a try statement in which the exception is caught how do you prevent the program from displaying error messages
This is is program whereby there exiext a button and a textfield , a figure is entered into the textfield , anytime the user presses the button th efolowing procedure is invoked.
I have written a try statement to check if the correct numbers are inputted, i want to stop the system from printing error messages if the try throws an exception pls how do i do this

public void actionPerformed(ActionEvent ae) {
int b=0;
// validate inputs
try {
Integer.parseInt(maxPoints.getText());
}
catch (NumberFormatException e){
JOptionPane.showMessageDialog(null, "the maximum points value must be a number",
"maximum points", JOptionPane.ERROR_MESSAGE);
}
 
Ranch Hand
Posts: 867
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi pamela
Welcome

If it is not clear,please reply again
thanks

[Broke up overlong line of code - Jim]
[ April 26, 2003: Message edited by: Jim Yingst ]
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The system, by default, doesn't show any messages when you catch an exception. The only reason the system does in this case is because you tell it to with the call to showMessageDialog(). If you get rid of that method call, then no message will be shown.
 
Water! People swim in water! Even tiny ads swim in water:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic