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

Perpixel Transparent Windows broken on Vista with Aero - Still shows window decorations

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • 6u10
    • client-libs
    • None
    • generic
    • windows_vista

      If you run the test case at the bottom below on windows XP then you get single Button displayed on screen with no window background or decorations painted around it. If you do the same on Windows Vista you get the button with the window background transparent but the window decorations are still painted. The decorations are not live they can not be clicked on, the mouse events pass though to what ever is behind the window. This bug is only with the Aero window manager enabled.

      I have found a almost workaround, it has the correct end result but has a nasty flicker/window zoom animation when you change from non-transparent to transparent window because thw window is being hidden and shown again. I have attached a full test app for the workaround.

      // WORKAROUND

      Point p = getLocation();
      Insets i = getInsets();
      setVisible(false);
      dispose();
      setUndecorated(jToggleButton1.isSelected());
      setLocation(p.x, p.y+i.top);
      AWTUtilities.setWindowOpaque(NewJFrame.this, !jToggleButton1.isSelected());
      setVisible(true);

      // TEST CASE

      import com.sun.awt.AWTUtilities;
      import java.awt.FlowLayout;
      import javax.swing.JButton;
      import javax.swing.JFrame;

      public class Main {

         public static void main(String args[]) {
             java.awt.EventQueue.invokeLater(new Runnable() {

                 public void run() {
                     JFrame frame = new JFrame("Test");
                     AWTUtilities.setWindowOpaque(frame, false);
                     JButton button = new JButton("Hello Everybody!");
                     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                     frame.getContentPane().setLayout(new FlowLayout());
                     frame.add(button);
                     frame.pack();
                     frame.setSize(400,400);
                     frame.setVisible(true);
                 }
             });
         }
      }

            anthony Anthony Petrov (Inactive)
            jasper Jasper Potts (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: