Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6738762

Showing glassPane in non-opaque toplevel makes the topLevel blank

    XMLWordPrintable

Details

    • b31
    • generic
    • generic

    Description

      If a window was made non opaque with help of the
      frame.setUndecorated(true);
      AWTUtilities.setWindowOpaque(frame, false);

      it is turned into the blank rectangle when glassPane is shown
      frame.getGlassPane().setVisible(true);

      I tested it on the latest JDK 6u11 build

      GlassPane tricks are quite popular among Swing programmers
      moreover this bug prevents resizing of internalFrames,
      because we temporarily show the glassPane when an internalFrame is being resized

      import com.sun.awt.AWTUtilities;

      import javax.swing.*;
      import java.awt.*;
      import java.awt.event.ActionListener;
      import java.awt.event.ActionEvent;

      public class GlassPanelTest {

          private static void createGui() {
              final JFrame frame = new JFrame();
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

              JButton button = new JButton("Show GlassPane");
              button.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent e) {
                      frame.getGlassPane().setVisible(true);
                  }
              });
              
              frame.add(button);
              
              frame.setSize(200, 200);
              frame.setLocationRelativeTo(null);

              frame.setUndecorated(true);
              AWTUtilities.setWindowOpaque(frame, false);
              
              frame.setVisible(true);
          }

          public static void main(String[] args) throws Exception {
              SwingUtilities.invokeLater(new Runnable() {
                  public void run() {
                      GlassPanelTest.createGui();
                  }
              });
          }
      }

      Attachments

        Issue Links

          Activity

            People

              anthony Anthony Petrov (Inactive)
              alexp Alexander Potochkin (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: