< prev index next >

src/java.desktop/windows/classes/sun/awt/windows/WPanelPeer.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -29,10 +29,18 @@
 
 import sun.awt.SunGraphicsCallback;
 
 class WPanelPeer extends WCanvasPeer implements PanelPeer {
 
+    // Default background.  Gets set on target if
+    // target has none explicitly specified.
+    static final Color defaultBackground = SystemColor.control;
+
+    // Default foreground.  Gets set on target if
+    // target has none explicitly specified.
+    static final Color defaultForeground = SystemColor.windowText;
+
     // ComponentPeer overrides
 
     @Override
     public void paint(Graphics g) {
         super.paint(g);

@@ -77,22 +85,19 @@
     @Override
     void initialize() {
         super.initialize();
         insets_ = new Insets(0,0,0,0);
 
-        Color c = ((Component)target).getBackground();
-        if (c == null) {
-            c = WColor.getDefaultColor(WColor.WINDOW_BKGND);
-            ((Component)target).setBackground(c);
-            setBackground(c);
-        }
-        c = ((Component)target).getForeground();
-        if (c == null) {
-            c = WColor.getDefaultColor(WColor.WINDOW_TEXT);
-            ((Component)target).setForeground(c);
-            setForeground(c);
+        if (!((Component) target).isBackgroundSet()) {
+            ((Component) target).setBackground(defaultBackground);
+            setBackground(defaultBackground);
+        }
+        if (!((Component) target).isForegroundSet()) {
+            ((Component) target).setForeground(defaultForeground);
+            setForeground(defaultForeground);
         }
+
     }
 
     /**
      * DEPRECATED:  Replaced by getInsets().
      */
< prev index next >