Click to See Complete Forum and Search --> : Blank input dialog box ....... error???


neo22
03-05-2006, 09:11 AM
Hi Everyone,

I am using the following code to accept inputs from the user:

String input = JOptionPane.showInputDialog("Input:");

Now the problem is .... if the user presses cancel ..... i have made the system to exit without the error bit ..... but if the user enters nothing .... it gives an error ..... how can i fix this problem ???? something like a custom message and make the program ask for the input again would be a better option but a simple exit will work as well ...

Thanks in advance

Phaelax
03-06-2006, 02:22 PM
if (input == null || input.equals(""))
System.exit(0);