This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Iterating Over All Swing Windows

 
Kaydell Leavitt
Ranch Hand
Posts: 689
Eclipse IDE Firefox Browser Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • 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: 689
Eclipse IDE Firefox Browser Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • 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
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • 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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic