Hi there,
I am attempting to validate a JOptionPane dialog for an empty input or if the cancel button is pressed by using the following line of code below:
String response;
response = JOptionPane.showInputDialog(null, "Please enter something");
if(response == null)
{
JOptionPane.showMessageDialog(null, "Error Message");
}
else
{
JOptionPane.showMessageDialog(null, "Thank you");
}
However it does not seem to be functioning like it should, I click the Ok button it just exits the application and gives a java generated error message and the same happens when I click the cancel button.
I would appreciate it if someone could explain why that is so..
Thanks