aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes opening multiple frames in a loop Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "opening multiple frames in a loop" Watch "opening multiple frames in a loop" New topic
Author

opening multiple frames in a loop

Ashish Sarin
author
Ranch Hand

Joined: Nov 20, 2000
Posts: 432
    
    5
I am using a for loop to create a JFrame. How can I make the program wait for the first window to close before opening the other one ?? I mean in what way I can make the for loop wait to excute the loop again.

regards,
Ashish Sarin


Author of
Getting started with Spring Framework
Portlets in Action
Spring Roo 1.1 Cookbook
Portlets blogSpring Roo blog
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

I'm not sure a for loop is going to be the best option for what you are trying to do. Which leads me to my next question...Why are you needing to pause between opening windows in a for loop?? What is the purpose of waiting for the window to close? Answering these questions might lead to a better solution than the one you are trying to implement.


GenRocket - Experts at Building Test Data
Ashish Sarin
author
Ranch Hand

Joined: Nov 20, 2000
Posts: 432
    
    5
I have to make a sequence of updates lets say. Each sequence has a different UI (which is dynamically generated from a method called from the for loop itself).
Ashish Sarin
author
Ranch Hand

Joined: Nov 20, 2000
Posts: 432
    
    5
I am not pausing before the opening window. I open one window then I want the second window to open ONLY after I close the first window. This isnt happening in the current case.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

It sounds to me like you are creating some sort of a "wizard" where you might have a next button, or in your case, a close button that activates the next part of the wizard.

You can't really pause a for loop. What you might do is add a windowlistener to your frames and on the windowsClosing or windowClosed events, generate your next JFrame (basically, just do whatever you were doing in your for loop, but do it in the windowClosing event method. Does that makes sense? Let me create some rough code, but it may be way off without really understanding your situation:



Does this help?
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
Not a for-loop, but a timer seems to work OK...

 
jQuery in Action, 2nd edition
 
subject: opening multiple frames in a loop