Если вы получаете NumberFormatException, то java не может анализировать, что бы это ни было, как число.
Другие вещи, которые нужно проверить, это пустые строки "" или нулевые строки (в этом случае это может привести кисключение нулевого указателя).
Возможно, также проверьте, есть ли ложные пробелы - избавьтесь от него с помощью обрезки, например
//get favorite number
String amountInput = textSeventh.getText();
if (amountInput == null) {
System.err.println("amountInput was null, no point continuing");
return;
}
// make it a bit more obvious if there's whitespace
System.out.println("amountInput = +++" + amountInput + "+++");
amountInput = amountInput.trim();
if (amountInput.equalsIgnoreCase("")) {
System.err.println("There's nothing there!!");
}
int dollars = -1337;
try {
dollars = Integer.parseInt(amountInput);
} catch (Exception e) {
System.err.println("Error when parsing value.\n" + e);
// optional
// e.printStackTrace();
}
System.out.println(dollars);