Can't have multiple modal dialogs?  What am I doing wrong?


Can't have multiple modal dialogs?  What am I doing wrong?
The following applet is a VERY stripped down version of what I am writing. I have an applet which creates modal dialog in which a user will enter data, then if the user tries to close without saving, I pop up another modal dialog to ask the user to save. Everything is fine that far, then, when the user dismisses that dialog, for example (with Cancel) or pressing the X, things look fine, it goes back to the first modal dialog, but that dialog is no longer modal! I can access the underlying applet. Here is a VERY stripped down version. What am I doing wrong? Help! Thanks!
import java.awt.*;
import java.awt.event.*;
import java.lang.*;
import javax.swing.*;
import java.util.*;
public class SherlockApplet extends JApplet
     public void init()
     // get root frame of applet
Component component = this;
while (component.getParent() != null)
component = component.getParent();
Frame appletFrame = (Frame) component;
// create a modal dialog with the root frame as the parent
JDialog firstModalDialog = new JDialog(appletFrame);
     firstModalDialog.setSize(200, 200);
     // create another modal dialog with the first dialog as the parent
     final JDialog secondModalDialog = new JDialog(firstModalDialog);
     secondModalDialog.setSize(100, 100);
     // add a listener to pop up the second modal dialog when we try to close the first
new WindowAdapter()
public void windowClosing(WindowEvent e);
// make sure not to close the first dialog if the user clicks the X
     // show the first dialog;
Good call dchsw, I tried 1.4.1_01 jre and it worked. If you run it with 1.3.0_01 jre you will see my problem. The problem for us is, we are stuck with 1.3.0_01 for our next release at least, due to Sun's decision to change event handling for java 1.4 jre and not make it backward compatible. I might have to hack my way around this one. Any other suggestions?
Read More: The other 4 answers