1
weightField.addKeyListener(new KeyAdapter() {
        public void keyTyped(KeyEvent e) {
            char c = e.getKeyChar();
            if (!((c >= '0') && (c <= '9') || (c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE))) {
              getToolkit().beep();
              e.consume();
            }
            if(serviceTypeComboBox.getSelectedIndex() == 0 && letterTypeComboBox.getSelectedIndex() == 0){
                priceField.setText(Integer.toString((Integer.parseInt(weightField.getText())/500) * 23000));
            }else if(serviceTypeComboBox.getSelectedIndex() == 0 && letterTypeComboBox.getSelectedIndex() == 1){
                priceField.setText(Integer.toString((Integer.parseInt(weightField.getText())/500) * 40000));
            }else if(serviceTypeComboBox.getSelectedIndex() == 1 && letterTypeComboBox.getSelectedIndex() == 0){
                priceField.setText(Integer.toString((Integer.parseInt(weightField.getText())/500) * 11000));
            }else if(serviceTypeComboBox.getSelectedIndex() == 1 && letterTypeComboBox.getSelectedIndex() == 1){
                priceField.setText(Integer.toString((Integer.parseInt(weightField.getText())/500) * 25000));
            }
        }});

キーを入力すると java.lang.NumberFormatException が発生する理由がわかりません...: スレッド "AWT-EventQueue-0" での例外 java.lang.NumberFormatException: For input string: ""

4

2 に答える 2