• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Junilu Lacar
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst
  • Peter Rooke
  • Mikalai Zaikin
Bartenders:
  • Himai Minh

opening multiple frames in a loop

 
author
Posts: 469
20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ashish Sarin
author
Posts: 469
20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 469
20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not a for-loop, but a timer seems to work OK...

 
Their achilles heel is the noogie! Give them noogies tiny ad!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic