closing multiple JFrames

I have JFrame1 that contains a button. This button when clicked creates multiples of JFrames, a minimum of 3. However, I wanted to add a button that will close those JFrames i opened..
[191 byte] By [chiwena] at [2007-11-26 18:17:54]
# 1
then your code needs to keep a track of all those jframes
georgemca at 2007-7-9 5:51:31 > top of Java-index,Java Essentials,Java Programming...
# 2
You mean I should remember all those JFrame objects? what is the method that closes JFrame aside from setDefaultCloseOperation?.Big Thanks!!
chiwena at 2007-7-9 5:51:31 > top of Java-index,Java Essentials,Java Programming...
# 3
setVisible(false) then stop referring to the object. it'll get GC'd (probably)
georgemca at 2007-7-9 5:51:31 > top of Java-index,Java Essentials,Java Programming...
# 4
setVisible(false) or dispose() ... or hide() [which is deprecated]
quittea at 2007-7-9 5:51:31 > top of Java-index,Java Essentials,Java Programming...
# 5
one more thing, can i keep track all of the windows that are open? can I decipher which is which?
chiwena at 2007-7-9 5:51:31 > top of Java-index,Java Essentials,Java Programming...
# 6
> one more thing, can i keep track all of the windows> that are open? can I decipher which is which?of course. whenever you create one, stick a reference to it in a collection. if you want to track them by name or something, use a Map of some sort, like HashMap
georgemca at 2007-7-9 5:51:31 > top of Java-index,Java Essentials,Java Programming...
# 7
hmmmm, a new concept to me.. I'll research about it. The application creates those frames inside a looping statement, is it possible to map that. Thanks
chiwena at 2007-7-9 5:51:31 > top of Java-index,Java Essentials,Java Programming...
# 8

Note that setVisible(false) only hides the frame (and afterwards it can be set visible again), whereas dispose() releases all resources used by that frame as well (and it cannot be restored). The method setDefaultCloseOperation(int) only sets the action taken when the user clicks on the x that closes a window.

#

duckbilla at 2007-7-9 5:51:31 > top of Java-index,Java Essentials,Java Programming...