Java Question

Java Swing - Keeping all JFrames together

I've got an application in which sometimes I use "modal", smaller windows. To simulate such modal behaviour what I do is defining them as extensions of JFrames, disabling the main application frame and setting the default close operation to do nothing. The problem of this is that JFrame can't have a parent so, when the user clicks the button said to close the window, it in fact closes and the system goes back to the last used application, which is not always the desired effect (e.g. the user opens the modal window, then he/she Alt+Tabs into another application, then switches back into the modal window and closes it, resulting this in being presented this last application, instead the main frame of mine). Is there any way to do this (binding JFrame to a parent or something like that...?). Note that JOptionPane is not an option because these smaller windows need to have like twenty different and custom Components inside each.


Why don't you use a JDialog? :-)