This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I have some experience in Java, but very little in Swing.
I'm doing a GUI application using Java Swing and the first thing I do is that the user enter a password and depending on whether correct or not repeat the process or continue. To do this I have a frame for the Login and another for the rest of application.
The problem is going back to restart Login if you put the wrong password.
I'm trying with Listeners and DoWhile but I think it's not the way.
I have a main class that calls the Login. If the password is correct, the login window disappears and another of a new class appears. This more or less OK.
If the password is wrong I can't return to the main and re-create the Object Login. I do everything within ActionPerformed of the OK button, but this method will not let me return anything, then that's where I stay.
I might be in the wrong way. I would appreciate advice, assistance or explanation of how you should do what I want.
If you need more information or details about what I want do not hesitate to ask.
In case the validation is more time consuming, a SwingWorker is probably a better idea. Disable the button, then start the SwingWorker. If that validates correctly you can dispose the dialog as Darryl has shown, otherwise re-enable the button and show an error.