java - StringUtils.isNumeric blocks JOptionPane cancel option -
this code i'm using process input of integer :
public static int getintinput(string message) { string numberstr = joptionpane.showinputdialog(message); while (!stringutils.isnumeric(numberstr) || integer.parseint(numberstr) == 0) { numberstr = joptionpane.showinputdialog(message); } return integer.parseint(numberstr); } it works fine, except when want press "cancel" or close button on joption window. when that, joptionpane window shows again.
how can correctly close joptionpane window when cancel or close button pushed?
while (!stringutils.isnumeric(numberstr) || integer.parseint(numberstr) == 0) { if (numberstr == null) { return 0; } else { numberstr = joptionpane.showinputdialog(message); } } this trick.
Comments
Post a Comment