Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: ""
나는 내가 내 번호를 입력하지 않고 계산하지 않기 때문에이 오류가 계속 왜 확실하지 오전 아래에 볼 수 빈 문자열에 대한 오류가 계속 JTextField. 아래는 계산 버튼에 사용하는 코드입니다. 상당히 간단합니다.
private void ButtonCalculateActionPerformed(java.awt.event.ActionEvent evt) {
Height = Integer.parseInt(this.TextFieldHeight.getText());
Weight = Integer.parseInt(this.TextFieldWeight.getText());
BMI = Integer.parseInt(this.TextFieldBMI.getText());
answer = Height + Weight;
this.TextFieldBMI.setText("The answer is: " + answer);
}
이
은 텍스트 필드 중 하나는 구문 분석 전에empty
검사를 추가해야
""
비어있는 동안
//variables
static int Height;
static int Weight;
static int BMI;
static int answer;
그게 전부 사실이 아니다, 나는 그 때 내가 계산하기 버튼을 눌렀을하고있는 JTextfields 내부에 숫자를 입력하고 난 오류가 위에서 언급 얻을. – ssj3goku878
추가 도움을 청하기 위해 [Minimal, Complete, Verifiable Example] (http://stackoverflow.com/help/mcve)을 게시하십시오. 당신이 보여주는 것은 당신이 당신의 문제를 푸는데 도움이 될 정도로 선명한 그림을 그리지 않습니다. –
this.TextFieldHeight.getText()는 저의 머리를 회전시킵니다. TextFieldHeight, TextFieldWeight 및 TextFieldBMI가 포함 된 클래스 계층 구조에 있으며 각 단계에서 재정의되는 정적 getText 메서드를 사용합니까? – Deltharis