Hi. I have a JOptionPane using showInputDialog() method. If the user doesn't key any text and hits OK, I want the dialog to stay up until they key something, or cancel it. My problem is if I hit OK without keying any text, the dialog stays up. But if I hit OK a second time, It goes away. I must be missing something. Could someone please help??
The following code will keep re-showing the dialog until non-empty input is entered. Note that a new dialog is shown each time. (A side effect is that if the dialog box is moved, it will show up in the center of the screen when you hit enter.) What was happening in your code was that you were showing the dialog twice (each time you call JOptionPane.showInputDialog), but no more. You also weren't resetting the value fo inputValue the second time you called it.