I wanted to validate the TextField of GUI, If user cannot enter string in size Text field that only take integers as an argument. Like catching Exceptions
Here is my code Its not catching the exception
public boolean validateTextField(){
if(eventSizeField.getText().isEmpty() || eventNameField.getText().isEmpty()){
alertboxCustom("Empty Field", "Please Enter Valid Name and size");
return false;
}else if(Integer.parseInt(eventSizeField.getText()) <= 0 ){
alertboxCustom("EventSize", "Event Size must be greater than zero");
return false;
}try{
Integer.parseInt(eventSizeField.getText());
}catch (NumberFormatException e) {
alertboxCustom("EventSize", e.getMessage());
System.out.println(e.getMessage());
return false;
}
return true;
}