So i have these lines:
try {
extra = Double.parseDouble(igu.txfExtra.getText());
} catch (NumberFormatException e1) {
System.out.print("Error");
}
It collects a double from a JTextField called txfExtra.
How can I say in the System.out.print if the error was made by introducing letters in the label for example? I mean, if the error was due to the "extra" collecting a String, show that the error was due to a string.
Also an extra question, how can i make "extra" to take values with BOTH "." and "," because due to localization it either takes for example "10.923" or either "10,923" i want it to accept both types of format when parsing the double.
Double.parseDouble()for your first requirement. As to the second,NumberFormatmay help. Also, do you accept numbers using the scientific notation?e1.printStackTrace();?parseDouble. Which is what fge was referring to with the NUMPATTERN.