Action when user press "Cancel"
try{
String string_months = JOptionPane.showInputDialog("Enter number of months:");
// return if user press cancel.
months = Integer.valueOf(string_months).intValue();
}catch (NumberFormatException f){
JOptionPane.showMessageDialog(null,"Only numbers allowed!");
this.getInput();
}
This code will never terminate. Is there someway to catch if the user press cancel?

