I currently have two frames, when you run the application the first JFrame that shows is a login, it has two input fields and a button. When the user logs in and is verified, I would like to close the frame and start up the second one.
So, the only thing I can think of doing is doing setVisible(false) for the login frame and setVisible(true) for the Main frame.
Is there a better way to do this, or is that the only way?
Personnally, I would start up your second
JFrameimmediately and replace your first frame with a modalJDialogwhich would be owned by theJFrame.See also this answer to The Use of Multiple JFrames, Good/Bad Practice?
Here is a basic demo of what I suggest: