• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Iterating Over All Swing Windows

 
Ranch Hand
Posts: 694
Mac OS X Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there a ways that I can get the front window in my Java SE app and then iterate over all of my JFrames?

For example, to implement a SaveAll command, I want to start with my front window and try to save it and then proceed to try to save all of my windows from front-to-back ordering.

Kaydell
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I generally keep a list of all open windows in the main class for this purpose.
 
Kaydell Leavitt
Ranch Hand
Posts: 694
Mac OS X Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to have -- not only a list of my own modeless windows -- but I need them in order. So would I have to keep some kind of list (probably a Collection) and keep track myself the current order?

I am implementing the following commands:

closeAll()
saveAll()
bringAllToFront()
and
quit() (which calls closeAll()

closeAll() need to close my modeless windows from front-to-back order.

Kaydell
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, you'd need to keep track of the window ordering. That could change a) whenever a new window is opened, b) whenever a window is closed and c) whenever the user clicks on a window to bring it to the front.

A LinkedList with its implied ordering might work well for this.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic