Urgent exception handeling!
Hello,
My problem is with exception handeling. I'm using java.awt. and i'm writing an application. My problem is i'm not really sure on how the format for exception handeling is.
public boolean action(Event evt, Object arg)
{
String str1 = textField1.getText();
String str2 = textField2.getText();
try
{
int int1 = Integer.parseInt(str1);
int int2 = Integer.parseInt(str2);
int answer = int1 / int2;
answerStr = String.valueOf(answer);
}
catch (NumberFormatException e)
{
answerStr = "Bad number!";
}
catch (ArithmeticException e)
{
answerStr = "Division by 0!";
}
repaint();
return true;
}
This works for text field contaning int but what if i whant to input a valid textfield containg string and int for example the input should be MH123 but instade enters 8976.
The other this is how do i implement JOptionPane into my code. Can JOptionPane be used in java.awt?
Thanks!
Your help is greatly appreaciated!
-pal_

