Well, I'm trying to create a way of detecting if the user inputs nothing and clicks 'OK.'
For example, if the user clicks cancel, I break out of a while loop with the following code:
if (words[i] == null) break; //breaks out of while loop
I tried something along these lines for a user clicking OK:
else if (Character.isDigit(words[i].charAt(0)) && words[i].charAt(0) == JOptionPane.OK_OPTION) break;
to break out of the loop if the user were to click OK, but no dice. I get this exception:
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(Unknown Source)
at Project1.main(Project1.java:21)
OK_OPTION
is of type int which is why I converted to int. Does anybody have any ideas of how I can do this?
I found this post about the 'Cancel' button but nothing about the 'OK' button. Thanks!