Doing a quick web search, it appears that clicking "Cancel" causes the input dialog to return null instead of a
String. You'll have to get the string returned by the dialog and
test it for null to do what you want. It might be a good idea anyway, just in case the user types "two", so you can control the error message he gets and try again.
rc