JOptionPane.showInputDialog and the cancel button
807598Mar 15 2006 — edited Apr 30 2006so i'm using a JOptionPane.showInputDialog, and everything works except when i click the cancel button to exit the window, it gives me an error.
how can i remedy this?
here's a section of my code: (a is an array, as is b)
firstWord = JOptionPane.showInputDialog
("What company's sloagan is/was: "+a[count]+"?");
if(firstWord.equalsIgnoreCase(b[count]))
{
JOptionPane.showMessageDialog (null,
"Thats Right, the company was "+b[count]+".");
count++;
int YesNo = JOptionPane.showConfirmDialog (null,
"Do you want to play again?", "Choose One", JOptionPane.YES_NO_OPTION,JOptionPane.INFORMATION_MESSAGE);
if(YesNo==1) //this should exit out if you click no
System.exit (0);
if(count==10)
{
JOptionPane.showMessageDialog(null,
"Game Over. You Won.");
System.exit (0);
}
}
else
{
JOptionPane.showMessageDialog (null,
"Sorry, you aren't that smart. Guess again.");
}
}]