Alex Rivera | Logout

Java swing application, close one window and open another when button is clicked

Asked 2012-03-05T19:46:48.827
16

I have a netbeans Java application that should display a JFrame (class StartUpWindow extends JFrame) with some options when the application is launched, then the user clicks a button and that JFrame should be closed and a new one (class MainWindow) should be opened.

So how do I do this correctly. I obviously set a click handler on the button in StartupWindow but what do I put in this handler so that I can close the StartUpWindow and open the MainWindow? It seems that threading comes into this too as every window seems to have their own thread...or are threading issues automatically handled by JFrames themselves...

Edit
Report

1 Answer

8

You can call dispose() on the current window and setVisible(true) on the one you want to display.

answered 2012-03-05T19:49:35.330

Your Answer