Reputation: 165
1 main program 2 JFrame programs.
How do I use the main program to call the JFrames to run during the main programs execution chromatically? (One at a time, one pops up user interacts and hits ok, the next frame pops up)
I've tried using this, but it executes both of the frames at the same time.
EventQueue.invokeLater(new Runnable() {
public void run() {
new chooseGender().setVisible(true);
}
});
Upvotes: 1
Views: 293
Reputation: 52185
You can either hide or dispose of the current JFrame.
To hide, you can call the .setVisible(false)
method, or if you no longer need the JFrame, simply call the .dispose()
method.
Note, you should create the new JFrame and hide/remove the current one, ideally in the event handler of the button which the user presses to go to the next screen.
Upvotes: 1