title: Modal JInternalFrames - GlassPane disappears after resizing
body: <p>First, I make GlassPane visible, then I add JInternalFrame to it. The GlassPane successfully blocks access to GUI elements under it HOWEVER when I try to resize JInternalFrame the GlassPane disappears and I have no idea why. </p>
  
  <p>The internal frame sits still on it. It looks like something changes setVisible method of the Glasspane to false... How to fix it?</p>
  
  <p>Here is some code. When I resize JInternalFrame the glassPane goes missing.</p>
  
  <pre><code>import java.awt.Cursor;
  import java.awt.event.*;
  import java.beans.PropertyVetoException;
  import javax.swing.*;
  import javax.swing.event.*;
  
  public class Example {
  
      private static JFrame frame = new JFrame();
      private static JDesktopPane glassPane = new JDesktopPane();
  
      public static void main(String[] args) {
          // make JDesktopPane (glassPane) transparent
          glassPane.setOpaque(false);
          // add empty mouse adapter to block events to other components then JInternalFrame
          glassPane.addMouseListener(new MouseAdapter(){});
          frame.setGlassPane(glassPane);
  
          final JInternalFrame internal = new JInternalFrame("testFrame", true, true);
          internal.setBounds(20, 20, 240, 200);
  
          // add listener to hide glassPane when  intenralFrame is closed
          internal.addInternalFrameListener(new InternalFrameListener(){
              public void internalFrameOpened(InternalFrameEvent e) {}
              public void internalFrameClosing(InternalFrameEvent e) {}
              public void internalFrameClosed(InternalFrameEvent e) {
                  glassPane.remove(internal);
                  glassPane.setVisible(false);
                  glassPane.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                  try {
                      internal.setClosed(true);
                  } catch (PropertyVetoException e1) {
                      e1.printStackTrace();
                  }           
              }
              public void internalFrameIconified(InternalFrameEvent e) {}
              public void internalFrameDeiconified(InternalFrameEvent e) {}
              public void internalFrameActivated(InternalFrameEvent e) {}
              public void internalFrameDeactivated(InternalFrameEvent e) {}
  
          });
  
          // adding exmaple components to frame
          frame.setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.PAGE_AXIS));
          frame.getContentPane().add(new JButton("button 1"));
          // button showing modal JInternalFrame
          JButton activate = new JButton("Show Modal InternalFrame");
          activate.addActionListener(new ActionListener(){
              public void actionPerformed(ActionEvent e) {
                  glassPane.add(internal);    
                  internal.setVisible(true);
                  glassPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                  glassPane.setVisible(true);
              }       
          });
          frame.getContentPane().add(activate);
  
          // example menu
          JMenuBar menuBar = new JMenuBar();
          JMenu menu = new JMenu("test menu");
          menu.add(new JMenuItem("test"));
          menuBar.add(menu);
          frame.setJMenuBar(menuBar);
          frame.setSize(800, 600);
          frame.setVisible(true);
      }
  }
  </code></pre>