6982279: java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java failed due to NPE
authoranthony
Mon, 04 Oct 2010 16:21:26 +0400
changeset 6645 63ea2d282026
parent 6644 ee35bd1e91f9
child 6646 a7518af86b7a
child 6819 3f85320a78af
6982279: java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java failed due to NPE Summary: Rely on the WWindowPeer.getTranslucentGraphics()'s return value Reviewed-by: art, dcherepanov
jdk/src/windows/classes/sun/awt/windows/WComponentPeer.java
jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java
--- a/jdk/src/windows/classes/sun/awt/windows/WComponentPeer.java	Mon Oct 04 16:12:07 2010 +0400
+++ b/jdk/src/windows/classes/sun/awt/windows/WComponentPeer.java	Mon Oct 04 16:21:26 2010 +0400
@@ -556,24 +556,26 @@
 
         Component target = (Component)getTarget();
         Window window = SunToolkit.getContainingWindow(target);
-        if (window != null && !window.isOpaque()) {
-            // Non-opaque windows do not support heavyweight children.
-            // Redirect all painting to the Window's Graphics instead.
-            // The caller is responsible for calling the
-            // WindowPeer.updateWindow() after painting has finished.
-            int x = 0, y = 0;
-            for (Component c = target; c != window; c = c.getParent()) {
-                x += c.getX();
-                y += c.getY();
-            }
-
+        if (window != null) {
             Graphics g =
                 ((WWindowPeer)window.getPeer()).getTranslucentGraphics();
+            // getTranslucentGraphics() returns non-null value for non-opaque windows only
+            if (g != null) {
+                // Non-opaque windows do not support heavyweight children.
+                // Redirect all painting to the Window's Graphics instead.
+                // The caller is responsible for calling the
+                // WindowPeer.updateWindow() after painting has finished.
+                int x = 0, y = 0;
+                for (Component c = target; c != window; c = c.getParent()) {
+                    x += c.getX();
+                    y += c.getY();
+                }
 
-            g.translate(x, y);
-            g.clipRect(0, 0, target.getWidth(), target.getHeight());
+                g.translate(x, y);
+                g.clipRect(0, 0, target.getWidth(), target.getHeight());
 
-            return g;
+                return g;
+            }
         }
 
         SurfaceData surfaceData = this.surfaceData;
--- a/jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java	Mon Oct 04 16:12:07 2010 +0400
+++ b/jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java	Mon Oct 04 16:21:26 2010 +0400
@@ -595,16 +595,6 @@
     }
 
     @Override
-    public Graphics getGraphics() {
-        synchronized (getStateLock()) {
-            if (!isOpaque) {
-                return getTranslucentGraphics();
-            }
-        }
-        return super.getGraphics();
-    }
-
-    @Override
     public void setBackground(Color c) {
         super.setBackground(c);
         synchronized (getStateLock()) {