我想知道你将如何去输出其中的两个文本框拖住NumberFormatException异常。NumberFormatException的2个文本框的Java
try
{
num1Convert = Integer.parseInt(num1Str);
num2Convert = Integer.parseInt(num2Str);
sumValue = num1Convert + num2Convert;
sumLabel.setText(sumText + Integer.toString(sumValue));
}
catch(NumberFormatException nfe)
{
errorLabel.setText((HERE IS WHERE I NEED TO PUT CODE TO SAY WHICH TEXTFIELD IT IS" must be an integer");
num1.requestFocus();
}
我的程序会比较两个数字,然后返回相加的数字的价值,但我需要这两个文本域的都扔回去异常输出,但我不知道如何做到这一点。我在代码中写过需要输出它的地方。
如何对两个单独的try catch块?或者这太明显了解决方案? –
的可能的复制[什么是NumberFormatException异常,我该如何解决?(http://stackoverflow.com/questions/39849984/what-is-a-numberformatexception-and-how-can-i-fix-it) – xenteros