当用户填写工资和加班文本字段时,假设要填写总薪资文本字段,但是一旦程序启动它总是显示java.lang.NumberFormatException:empty String error
这是使用的代码
private void jTextGrossPayMouseEntered(java.awt.event.MouseEvent evt) { try{ DecimalFormat numberFormat = new DecimalFormat("#.00"); double salary = Double.parseDouble(jTextBasicSalary.getText()); double hours = Double.parseDouble(jTextHours.getText()); double overtime = Double.parseDouble(jTextOvertime.getText()); double overtimepay = Double.parseDouble(jTextOvertimePay.getText()); double total1; double total2; double total3; total1 = salary * hours; total2 = overtime * overtimepay; total3 = total1 + total2; String gross = String.valueOf(total3); jTextGrossPay.setText(gross); } catch(Exception e){ e.printStackTrace(); } }
在我运行程序后,这些都是错误
java.lang.NumberFormatException:empty String
浮云间
白板的微信
相关分类