Still get a NullPointerException
If the user clicks on the cancel button in a JOptionPane box I get a NullPointerException. Even when I added the code for the Cancel button I still get a NullPointerException.
public String askQuestion(String question)
{
String answerToQuestion = JOptionPane.showInputDialog(question);
while (answerToQuestion.equals("") || Integer.parseInt(answerToQuestion)
==JOptionPane.CANCEL_OPTION))
{
answerToQuestion = JOptionPane.showInputDialog(question);
}
return answerToQuestion;
}
What's the problem?
Thanks

