jdk/src/share/classes/java/awt/Component.java
changeset 2459 08f3416ff334
parent 2451 597df8e1d786
child 2462 192552ca8292
--- a/jdk/src/share/classes/java/awt/Component.java	Thu Feb 19 14:10:19 2009 +0300
+++ b/jdk/src/share/classes/java/awt/Component.java	Fri Feb 20 17:34:16 2009 +0300
@@ -300,7 +300,7 @@
      * @see GraphicsConfiguration
      * @see #getGraphicsConfiguration
      */
-    transient GraphicsConfiguration graphicsConfig = null;
+    private transient GraphicsConfiguration graphicsConfig = null;
 
     /**
      * A reference to a <code>BufferStrategy</code> object
@@ -845,6 +845,12 @@
                     }
                 }
             }
+
+            public void setGraphicsConfiguration(Component comp,
+                    GraphicsConfiguration gc)
+            {
+                comp.setGraphicsConfiguration(gc);
+            }
         });
     }
 
@@ -1012,50 +1018,21 @@
      */
     public GraphicsConfiguration getGraphicsConfiguration() {
         synchronized(getTreeLock()) {
-            if (graphicsConfig != null) {
-                return graphicsConfig;
-            } else if (getParent() != null) {
-                return getParent().getGraphicsConfiguration();
-            } else {
-                return null;
-            }
+            return getGraphicsConfiguration_NoClientCode();
         }
     }
 
     final GraphicsConfiguration getGraphicsConfiguration_NoClientCode() {
-        GraphicsConfiguration graphicsConfig = this.graphicsConfig;
-        Container parent = this.parent;
-        if (graphicsConfig != null) {
-            return graphicsConfig;
-        } else if (parent != null) {
-            return parent.getGraphicsConfiguration_NoClientCode();
-        } else {
-            return null;
-        }
-    }
-
-    /**
-     * Resets this <code>Component</code>'s
-     * <code>GraphicsConfiguration</code> back to a default
-     * value.  For most componenets, this is <code>null</code>.
-     * Called from the Toolkit thread, so NO CLIENT CODE.
-     */
-    void resetGC() {
+        return graphicsConfig;
+    }
+
+    void setGraphicsConfiguration(GraphicsConfiguration gc) {
         synchronized(getTreeLock()) {
-            graphicsConfig = null;
-        }
-    }
-
-    /*
-     * Not called on Component, but needed for Canvas and Window
-     */
-    void setGCFromPeer() {
-        synchronized(getTreeLock()) {
-            if (peer != null) { // can't imagine how this will be false,
-                                // but just in case
-                graphicsConfig = peer.getGraphicsConfiguration();
-            } else {
-                graphicsConfig = null;
+            graphicsConfig = gc;
+
+            ComponentPeer peer = getPeer();
+            if (peer != null) {
+                peer.updateGraphicsData(gc);
             }
         }
     }