删除文本框内容时出错

时间:2017-12-08 15:34:20

标签: java netbeans textbox

删除文本框中的内容时出现错误我不知道为什么?

Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: empty String
    at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1842)
    at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
    at java.lang.Double.parseDouble(Double.java:538)
    at Frame.MainMenu.txt_payment_paymentKeyReleased(MainMenu.java:2198)

这里

private void txt_payment_paymentKeyReleased(java.awt.event.KeyEvent evt) {                                                
          // payers();
          if(txt_payment_payment.equals("")){
           txt_payment_change.setText("");
          }else{
            double a = Double.parseDouble(txt_payment_total.getText());
            double b = Double.parseDouble(txt_payment_payment.getText());

            double total = (b-a);
         txt_payment_change.setText(Double.toString(total));
          }
        }  

see picture below

0 个答案:

没有答案