JOptionPane can be used to get string inputs from user, but in my case, I want to display a password field in showInputDialog.
The way I ne
This dialogue looks a lot better if you do
dlg.setVisible(true);
Without that you can't see it at all.
Also
pPnl.gainedFocus();
should be
pPnl.gainedFocus();
Other than that it works great. Thanks for the code. Saved me time facing around with Swing.
Also, if you don't want to leave the dialogue running in the background every time you open it, you'll need to close it with something like
dlg.dispatchEvent(new WindowEvent(dlg, WindowEvent.WINDOW_CLOSING));
dlg.dispose(); // else java VM will wait for dialog to be disposed of (forever)