title: Modal Window on top of Modal Window in java swing?
body: <p>I have the following problem:</p>
  
  <p>I have a main application window (JFrame) that fills the whole screen.<br>
  When a button is clicked, a smaller window appears, to let the user input some Data. While the User does this, the main window should neither jump in front of it, nor allow interaction.<br>
  Solution to that: open a modal JDialog. Lets call that Dialog 1.<br>
  But when a button within this Dialog is clicked, a NEW window (yes/no-dialog) is supposed to pop up.. and, again, needs to act modal on the already modal JDialog Dialog 1. Trying to do that, the second Dialog keeps disappearing behind the first one.<br>
  I tried making Dialog 1 a JFrame but then, of course, I loose the "modal" bit. Forcing Dialog 1 to stay in from still keeps the main window's Button clickable.<br>
  What am I missing? How can I put a modal swing window OVER another modal swing window?</p>
  
  <p>Edit:
  minimal example of one not-really working version:</p>
  
  <p>Main class for opening:</p>
  
  <pre><code>public class MainWin extends JFrame {
  
  public MainWin(){
      this.setSize(800,800);
      JButton b = new JButton("click hehe");
      this.getContentPane().add(b);
      b.addActionListener(new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
              new Dia1(MainWin.this);
          }
      });
      this.setVisible(true);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Main window:  </p>
  
  <pre><code> public class MainWin extends JFrame {
  
  public MainWin(){
      this.setSize(800,800);
      JButton b = new JButton("click hehe");
      this.getContentPane().add(b);
      b.addActionListener(new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
              new Dia1(MainWin.this);
          }
      });
      this.setVisible(true);
  }
  }
  </code></pre>
  
  <p>First Dialog:</p>
  
  <pre><code>public class Dia1 extends JDialog {
  
  
  public Dia1(final JFrame parent){
      super(parent, true);
      this.setSize(400, 400);
      JButton b = new JButton("click hehe");
      this.getContentPane().add(b);
      this.setVisible(true);
      b.addActionListener(new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
              new Dia2(parent);
          }
      });
  }
  }
  </code></pre>
  
  <p>Second Dialog:</p>
  
  <pre><code>public class Dia2 extends JDialog {
  
  
  public Dia2(JFrame parent){
      super(parent, true);
      this.setSize(200, 200);
      JButton b = new JButton("click hehe");
      this.getContentPane().add(b);
      this.setVisible(true);
  }
  
  }
  </code></pre>
  
  <p>PS: I just realised: Dialog 2 is not hidden, as I suspected.. it is simply not there. Most likely because the parent window is blocked from the Modal Dialog?</p>