Take a look at the JavaDocs for Integer.getInteger(String, Integer)
for a sec
Returns:
the Integer value of the property.
Or in longer terms...
Returns the integer value of the system property with the specified
name. The first argument is treated as the name of a system property.
System properties are accessible through the
System.getProperty(java.lang.String) method. The string value of this
property is then interpreted as an integer value, as per the
Integer.decode method, and an Integer object representing this value
is returned.
- If the property value begins with the two ASCII characters 0x or the ASCII character #, not followed by a minus sign, then the rest of
it is parsed as a hexadecimal integer exactly as by the method
valueOf(java.lang.String, int) with radix 16.
- If the property value begins with the ASCII character 0 followed by another character, it is parsed as an octal integer exactly as by the
method valueOf(java.lang.String, int) with radix 8.
- Otherwise, the property value is parsed as a decimal integer exactly as by the method valueOf(java.lang.String, int) with radix
10.
The second argument is the default value. The default value is
returned if there is no property of the specified name, if the
property does not have the correct numeric format, or if the specified
name is empty or null.
This is not doing what you think it is...
Instead you should be using Integer.parseInt(String)
, this will throw a NumberFormatException
when the value of the String
can't be converted to a valid integer...
For example...
String x = textfield_1.getText();
String y = textfield_2.getText();
try {
Integer integerfield_1 = Integer.parseInt(textfield_1.getText());
System.out.println("Please Enter The Position");
//TODO Fill GUI Form.
} catch (NumberFormatException exp) {
exp.printStackTrace();
System.out.println("Incorrect Integer (Integer Only)");
}