Exception when clicks Cancel button in JDialog

I am trying to implement a JDialog at the end of a program and collect the user's input. My problem is that when the user clicks the "Cancel" button, Eclipse shows:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException.

The program seems running OK though afterwards. I can still start a new game etc. What is the code that I need to add in order to get rid of this NullPointerException?

If you read the docs you'll see that JOptionPane.showInputDialog returns null if the user canceled the input.
You should check your String s for not being before using it.