• Post Reply Bookmark Topic Watch Topic
  • New Topic

Doubt in Swing

 
Thyagarajan Ramanujam
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a swing frame, let the name be Frame1. On the click of a button, another frame is opened, let its name be Frame2. The two frames are in two separate classes and they dont extend any class.

The code given below is written in the actionPerformed() method of Frame1 class

if(e.getActionCommand().equals("Click here too"))
{

Frame2 object = new Frame2();
object.setVisible(true);

for(int i = 0; i< 10;i++)
System.out.println("Executing..... parentform");
}

Normally, this code shows the frame2 and then starts executing the for loop.

Is it possible to temporarily stop the execution of frame1 till the frame2 is closed. That ie, here the execution of the for loop should happen only when the Frame2 is closed.

Is there any solution for this without using
 
Rob Spoor
Sheriff
Posts: 20820
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without using what?

It seems that you might want to consider a modal dialog instead of a frame. For modal dialogs, the setVisible(true) call is blocking until the dialog is closed.
 
Thyagarajan Ramanujam
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Using modal dialog works for me.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!