Those Pesky JFrames

Hey there,

I have a jframe, in which when i click a button it launches a new jframe.

Pretty simple..

However in the method that launches the new jframe i have further instructions proceeding the new jframe call which i dont want executed until work in the new jframe is completed.

Is there a way for me to put the calling jframe on hold until the new jframe either closes or notifies the caller that work has finished?

example:

private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {

NewJFrame1 b = new NewJFrame1();

//Dont want these methods to be called until the jFrame b completes

this.doSomeMoreWork();

that.doSomeWorkAlso();

}

Many Thanks

[734 byte] By [dobsuna] at [2007-11-26 17:10:05]
# 1
Pesky?
kirillga at 2007-7-8 23:37:55 > top of Java-index,Desktop,Core GUI APIs...
# 2
Dont get me wrong i really like em :)
dobsuna at 2007-7-8 23:37:55 > top of Java-index,Desktop,Core GUI APIs...
# 3
The second JFrame should be a JDialog (not a JFrame) and make the dialog modal but don't forget to specify the primary JFrame as the owner of the dialog.
camickra at 2007-7-8 23:37:56 > top of Java-index,Desktop,Core GUI APIs...
# 4

You can still have it as a frame. Define method on Frame1:

public void doPostFrame2() {

doSomeWork();

doSomeMoreWork();

if (CharlesBronson.isAlive()) {

kill(self);

}

}

Now, pass the Frame1 instance to Frame2:

public Frame2(Frame1 caller) {

this.caller = caller;

}

After Frame2 is gone (add window listener), do this.caller.doPostFrame2.

Another option is to register window listener directly from Frame1's button listener.

kirillga at 2007-7-8 23:37:56 > top of Java-index,Desktop,Core GUI APIs...