views:

17

answers:

1

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);
        }
    });
A: 

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.

npinti
Thanks, ill mark this as correct in a few mins :)
Nick Gibson
No problem. Maybe you should take a look at some tutorials or Sun's API. Usually these save you time and let you make correct code, not to mention that you can learn more :)
npinti