The best way to do that would be to put them on consecutive lines inside one of the methods of your class. Just as you did in the example you posted. The JVM always executes statements sequentially if they are written that way.
Yeah i have done that but it does not produce the desired effect. The function that is being called produces a jframe object which requires user interaction. so essentially i get two jframes, instead of the desired one jframe, wait for interaction then the other jframe?
When creating a jframe object is a new thread of execution created?
Yes, when creating a JFrame, the user interaction is performed in a different thread - the Event Dispatch Thread (also referred to as 'the GUI thread' sometimes). If you want to block the main thread from finishing (keep the first method from finishing and the second method from starting) you don't want to use a JFrame. You want to use a Modal dialog which blocks the triggering thread. I believe JOptionPane might work if you have relatively simple interaction with the user in mind.
If the interaction is not so simple your approach may be upside down. Instead of having the main thread dictate order by creating a GUI, blocking until the GUI is finished, then creating a new GUI, you might consider using the GUI as the driver to trigger settings/configuration and eventually, when required, to destroy or hide one JFrame and display a different one.
I am Arthur, King of the Britons. And this is a tiny ad: