String str = JTextField.getText();try { int zahl = Integer.parseInt(str);}catch (NumberFormatException nfe){}