Java: JOptionPane affects parent JFrame? (includes SSCE)
Given the following applet:
    
    import java.awt.BorderLayout;
    import java.awt.Rectangle;
    import java.lang.reflect.InvocationTargetException;
    
    import javax.swing.JApplet;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    
    public class Example extends JApplet
    {
       JPanel aPanel;
    
       @Override
       public void init()
       {
          try
          {
             javax.swing.SwingUtilities.invokeAndWait(new Runnable()
             {
                public void run()
                {
                   makeGui();
                }
             });
          }
          catch (InterruptedException e)
          {
             // TODO Auto-generated catch block
             e.printStackTrace();
          }
          catch (InvocationTargetException e)
          {
             // TODO Auto-generated catch block
             e.printStackTrace();
          }      
       }
       
       public void makeGui()
       {
          aPanel = new JPanel(new BorderLayout());
          
          this.getContentPane().add(aPanel, BorderLayout.CENTER);
          
          JFrame aTestFrame =new JFrame();
          aTestFrame.setBounds(new Rectangle(200,200));
          JPanel aTestPanel = new JPanel(new BorderLayout());
          aTestPanel.setBounds(new Rectangle(200,200));
          
          aTestFrame.add(aTestPanel);
          aTestFrame.setVisible(true);
          JOptionPane.showMessageDialog(aTestFrame, "arfarf");
          
          
       }
       
    }
    
Why does the JOptionPane call closes aTestFrame? If i leave out the call the 2 frames render correctly, but when i click on OK in the JOptionPane the parent JFrame is closed.
Java: JOptionPane affects parent JFrame? (includes SSCE)
===

Given the following applet:
    
    import java.awt.BorderLayout;
    import java.awt.Rectangle;
    import java.lang.reflect.InvocationTargetException;
    
    import javax.swing.JApplet;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    
    public class Example extends JApplet
    {
       JPanel aPanel;
    
       @Override
       public void init()
       {
          try
          {
             javax.swing.SwingUtilities.invokeAndWait(new Runnable()
             {
                public void run()
                {
                   makeGui();
                }
             });
          }
          catch (InterruptedException e)
          {
             // TODO Auto-generated catch block
             e.printStackTrace();
          }
          catch (InvocationTargetException e)
          {
             // TODO Auto-generated catch block
             e.printStackTrace();
          }      
       }
       
       public void makeGui()
       {
          aPanel = new JPanel(new BorderLayout());
          
          this.getContentPane().add(aPanel, BorderLayout.CENTER);
          
          JFrame aTestFrame =new JFrame();
          aTestFrame.setBounds(new Rectangle(200,200));
          JPanel aTestPanel = new JPanel(new BorderLayout());
          aTestPanel.setBounds(new Rectangle(200,200));
          
          aTestFrame.add(aTestPanel);
          aTestFrame.setVisible(true);
          JOptionPane.showMessageDialog(aTestFrame, "arfarf");
          
          
       }
       
    }
    
Why does the JOptionPane call closes aTestFrame? If i leave out the call the 2 frames render correctly, but when i click on OK in the JOptionPane the parent JFrame is closed.