--- old/src/java.desktop/windows/classes/sun/awt/windows/WWindowPeer.java 2016-05-17 16:12:38.709255000 +0530 +++ new/src/java.desktop/windows/classes/sun/awt/windows/WWindowPeer.java 2016-05-17 16:12:38.533166999 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2015, 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 @@ -177,12 +177,11 @@ updateInsets(insets_); - Font f = ((Window)target).getFont(); - if (f == null) { - f = defaultFont; - ((Window)target).setFont(f); - setFont(f); + if (!((Window) target).isFontSet()) { + ((Window) target).setFont(defaultFont); + setFont(defaultFont); } + // Express our interest in display changes GraphicsConfiguration gc = getGraphicsConfiguration(); ((Win32GraphicsDevice)gc.getDevice()).addDisplayChangedListener(this); --- old/src/java.desktop/windows/classes/sun/awt/windows/WPanelPeer.java 2016-05-17 16:12:39.229515000 +0530 +++ new/src/java.desktop/windows/classes/sun/awt/windows/WPanelPeer.java 2016-05-17 16:12:39.041420999 +0530 @@ -1,5 +1,5 @@ /* - * 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 @@ -79,18 +79,18 @@ super.initialize(); insets_ = new Insets(0,0,0,0); - Color c = ((Component)target).getBackground(); - if (c == null) { + Color c = null; + if (!((Component) target).isBackgroundSet()) { c = WColor.getDefaultColor(WColor.WINDOW_BKGND); - ((Component)target).setBackground(c); + ((Component) target).setBackground(c); setBackground(c); } - c = ((Component)target).getForeground(); - if (c == null) { + if (!((Component) target).isForegroundSet()) { c = WColor.getDefaultColor(WColor.WINDOW_TEXT); - ((Component)target).setForeground(c); + ((Component) target).setForeground(c); setForeground(c); } + } /** --- old/src/java.desktop/windows/classes/sun/awt/windows/WDialogPeer.java 2016-05-17 16:12:39.805803000 +0530 +++ new/src/java.desktop/windows/classes/sun/awt/windows/WDialogPeer.java 2016-05-17 16:12:39.593696999 +0530 @@ -37,10 +37,6 @@ // target has none explicitly specified. static final Color defaultBackground = SystemColor.control; - // If target doesn't have its background color set, we set its - // background to platform default. - boolean needDefaultBackground; - WDialogPeer(Dialog target) { super(target); @@ -67,7 +63,7 @@ Dialog target = (Dialog)this.target; // Need to set target's background to default _before_ a call // to super.initialize. - if (needDefaultBackground) { + if (!target.isBackgroundSet()) { target.setBackground(defaultBackground); } @@ -132,20 +128,7 @@ reshapeFrame(x, y, width, height); } } - - /* Native create() peeks at target's background and if it's null - * calls this method to arrage for default background to be set on - * target. Can't make the check in Java, since getBackground will - * return owner's background if target has none set. - */ - private void setDefaultColor() { - // Can't call target.setBackground directly, since we are - // called on toolkit thread. Can't schedule a Runnable on the - // EventHandlerThread because of the race condition. So just - // set a flag and call target.setBackground in initialize. - needDefaultBackground = true; - } - + native void pSetIMMOption(String option); void notifyIMMOptionChange(){ InputMethodManager.getInstance().notifyChangeRequest((Component)target); --- old/src/java.desktop/windows/native/libawt/windows/awt_Dialog.cpp 2016-05-17 16:12:40.286043000 +0530 +++ new/src/java.desktop/windows/native/libawt/windows/awt_Dialog.cpp 2016-05-17 16:12:40.081941000 +0530 @@ -1,5 +1,5 @@ /* - * 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 @@ -100,7 +100,6 @@ { JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); - jobject background = NULL; jobject target = NULL; AwtDialog* dialog = NULL; @@ -181,22 +180,13 @@ } dialog->DoUpdateIcon(); - - background = env->GetObjectField(target, - AwtComponent::backgroundID); - if (background == NULL) { - JNU_CallMethodByName(env, NULL, - peer, "setDefaultColor", "()V"); - } } } catch (...) { - env->DeleteLocalRef(background); env->DeleteLocalRef(target); throw; } done: - env->DeleteLocalRef(background); env->DeleteLocalRef(target); return dialog; --- old/src/java.desktop/unix/classes/sun/awt/X11/XWindowPeer.java 2016-05-17 16:12:40.870335000 +0530 +++ new/src/java.desktop/unix/classes/sun/awt/X11/XWindowPeer.java 2016-05-17 16:12:40.650225000 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -174,27 +174,24 @@ cachedFocusableWindow = isFocusableWindow(); - Font f = target.getFont(); - if (f == null) { - f = XWindow.getDefaultFont(); - target.setFont(f); - // we should not call setFont because it will call a repaint - // which the peer may not be ready to do yet. + if (!target.isFontSet()) { + target.setFont(XWindow.getDefaultFont()); + // we should not call setFont because it will call a repaint + // which the peer may not be ready to do yet. } - Color c = target.getBackground(); - if (c == null) { - Color background = SystemColor.window; - target.setBackground(background); - // we should not call setBackGround because it will call a repaint - // which the peer may not be ready to do yet. + if (!target.isBackgroundSet()) { + target.setBackground(SystemColor.window); + // we should not call setBackGround because it will call a repaint + // which the peer may not be ready to do yet. + } - c = target.getForeground(); - if (c == null) { - target.setForeground(SystemColor.windowText); - // we should not call setForeGround because it will call a repaint - // which the peer may not be ready to do yet. + if (!target.isForegroundSet()) { + target.setForeground(SystemColor.windowText); + // we should not call setForeGround because it will call a repaint + // which the peer may not be ready to do yet. } + alwaysOnTop = ((Window)target).isAlwaysOnTop() && ((Window)target).isAlwaysOnTopSupported(); GraphicsConfiguration gc = getGraphicsConfiguration(); --- /dev/null 2016-05-17 10:45:04.564813000 +0530 +++ new/test/java/awt/Dialog/ChildProperties/ChildDialogProperties.java 2016-05-17 16:12:41.234517000 +0530 @@ -0,0 +1,151 @@ +/* + * Copyright (c) 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + /* + @test + @bug 8057574 + @summary Verify that child Dialog does not inherit parent's Properties + @run main ChildDialogProperties + */ +import java.awt.Color; +import java.awt.Dialog; +import java.awt.Font; +import java.awt.Frame; +import java.awt.Label; + +public class ChildDialogProperties { + + private Dialog parentDialog; + private Dialog dialogChild; + private Frame parentFrame; + private Dialog frameChildDialog; + private Label parentLabel; + private Font parentFont; + private Label childLabel; + + private static final int WIDTH = 200; + private static final int HEIGHT = 200; + + public void testChildPropertiesWithDialogAsParent() { + + parentDialog = new Dialog((Dialog) null, "parent Dialog"); + parentDialog.setSize(WIDTH, HEIGHT); + parentDialog.setLocation(100, 100); + parentDialog.setBackground(Color.RED); + + parentLabel = new Label("ParentForegroundAndFont"); + parentFont = new Font("Courier New", Font.ITALIC, 15); + parentDialog.setForeground(Color.BLUE); + parentDialog.setFont(parentFont); + + parentDialog.add(parentLabel); + parentDialog.setVisible(true); + + dialogChild = new Dialog(parentDialog, "Dialog's child"); + dialogChild.setSize(WIDTH, HEIGHT); + dialogChild.setLocation(WIDTH + 200, 100); + childLabel = new Label("ChildForegroundAndFont"); + dialogChild.add(childLabel); + + dialogChild.setVisible(true); + + if (parentDialog.getBackground() == dialogChild.getBackground()) { + dispose(); + throw new RuntimeException("Child Dialog Should NOT Inherit " + + "Parent Dialog's Background Color"); + } + + if (parentDialog.getForeground() == dialogChild.getForeground()) { + dispose(); + throw new RuntimeException("Child Dialog Should NOT Inherit " + + "Parent Dialog's Foreground Color"); + } + + if (parentDialog.getFont() == dialogChild.getFont()) { + dispose(); + throw new RuntimeException("Child Dialog Should NOT Inherit " + + "Parent Dialog's Font Style/Color"); + } + + } + + public void testChildPropertiesWithFrameAsParent() { + + parentFrame = new Frame("parent Frame"); + parentFrame.setSize(WIDTH, HEIGHT); + parentFrame.setLocation(100, 400); + parentFrame.setBackground(Color.BLUE); + parentLabel = new Label("ParentForegroundAndFont"); + parentFont = new Font("Courier New", Font.ITALIC, 15); + parentFrame.setForeground(Color.RED); + parentFrame.setFont(parentFont); + parentFrame.add(parentLabel); + parentFrame.setVisible(true); + + frameChildDialog = new Dialog(parentFrame, "Frame's child"); + frameChildDialog.setSize(WIDTH, HEIGHT); + frameChildDialog.setLocation(WIDTH + 200, 400); + childLabel = new Label("ChildForegroundAndFont"); + frameChildDialog.add(childLabel); + frameChildDialog.setVisible(true); + + if (parentFrame.getBackground() == frameChildDialog.getBackground()) { + dispose(); + throw new RuntimeException("Child Dialog Should NOT Inherit " + + "Parent Frame's Background Color"); + } + + if (parentFrame.getForeground() == frameChildDialog.getForeground()) { + dispose(); + throw new RuntimeException("Child Dialog Should NOT Inherit " + + "Parent Frame's Foreground Color"); + } + + if (parentFrame.getFont() == frameChildDialog.getFont()) { + dispose(); + throw new RuntimeException("Child Dialog Should NOT Inherit " + + "Parent Frame's Font Style/Color"); + } + } + + private void dispose() { + + if (parentDialog != null) { + parentDialog.dispose(); + } + if (parentFrame != null) { + parentFrame.dispose(); + } + } + + public static void main(String[] args) throws Exception { + + ChildDialogProperties obj = new ChildDialogProperties(); + // TestCase1: When Parent is Dialog, Child is Dialog + obj.testChildPropertiesWithDialogAsParent(); + // TestCase2: When Parent is Frame, chis is Dialog + obj.testChildPropertiesWithFrameAsParent(); + obj.dispose(); + } + +} --- /dev/null 2016-05-17 10:45:04.564813000 +0530 +++ new/test/java/awt/Window/ChildProperties/ChildWindowProperties.java 2016-05-17 16:12:41.722761000 +0530 @@ -0,0 +1,145 @@ +/* + * Copyright (c) 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + /* + @test + @bug 8057574 + @summary Verify that child Window does not inherit parent's Properties + @run main ChildWindowProperties + */ +import java.awt.Color; +import java.awt.Dialog; +import java.awt.Font; +import java.awt.Frame; +import java.awt.Label; +import java.awt.Window; + +public class ChildWindowProperties { + + private Dialog parentDialog; + private Window windowChild; + private Frame parentFrame; + private Window frameChildWindow; + private Label parentLabel; + private Font parentFont; + private Label childLabel; + + private static final int WIDTH = 200; + private static final int HEIGHT = 200; + + public void testChildPropertiesWithDialogAsParent() { + + parentDialog = new Dialog((Dialog) null, "parent Dialog"); + parentDialog.setSize(WIDTH, HEIGHT); + parentDialog.setLocation(100, 100); + parentDialog.setBackground(Color.RED); + parentLabel = new Label("ParentForegroundAndFont"); + parentFont = new Font("Courier New", Font.ITALIC, 15); + parentDialog.setForeground(Color.BLUE); + parentDialog.setFont(parentFont); + + parentDialog.add(parentLabel); + parentDialog.setVisible(true); + + windowChild = new Window(parentDialog); + windowChild.setSize(WIDTH, HEIGHT); + windowChild.setLocation(WIDTH + 200, 100); + childLabel = new Label("ChildForegroundAndFont"); + windowChild.add(childLabel); + windowChild.setVisible(true); + + if (parentDialog.getBackground() == windowChild.getBackground()) { + dispose(); + throw new RuntimeException("Child Window Should NOT Inherit " + + "Parent Dialog's Background Color"); + } + if (parentDialog.getForeground() == windowChild.getForeground()) { + dispose(); + throw new RuntimeException("Child Window Should NOT Inherit " + + "Parent Dialog's Foreground Color"); + } + if (parentDialog.getFont() == windowChild.getFont()) { + dispose(); + throw new RuntimeException("Child Window Should NOT Inherit " + + "Parent Dialog's Font Color"); + } + } + + public void testChildPropertiesWithFrameAsParent() { + + parentFrame = new Frame("parent Frame"); + parentFrame.setSize(WIDTH, HEIGHT); + parentFrame.setLocation(100, 400); + parentFrame.setBackground(Color.BLUE); + parentLabel = new Label("ParentForegroundAndFont"); + parentFont = new Font("Courier New", Font.ITALIC, 15); + parentFrame.setForeground(Color.RED); + parentFrame.setFont(parentFont); + parentFrame.add(parentLabel); + parentFrame.setVisible(true); + + frameChildWindow = new Window(parentFrame); + frameChildWindow.setSize(WIDTH, HEIGHT); + frameChildWindow.setLocation(WIDTH + 200, 400); + childLabel = new Label("ChildForegroundAndFont"); + frameChildWindow.add(childLabel); + frameChildWindow.setVisible(true); + + if (parentFrame.getBackground() == frameChildWindow.getBackground()) { + dispose(); + throw new RuntimeException("Child Window Should NOT Inherit " + + "Parent Frame's Background Color"); + } + if (parentDialog.getForeground() == windowChild.getForeground()) { + dispose(); + throw new RuntimeException("Child Window Should NOT Inherit " + + "Parent Frame's Foreground Color"); + } + if (parentDialog.getFont() == windowChild.getFont()) { + dispose(); + throw new RuntimeException("Child Window Should NOT Inherit " + + "Parent Frame's Font Color"); + } + } + + private void dispose() { + + if (parentDialog != null) { + parentDialog.dispose(); + } + if (parentFrame != null) { + parentFrame.dispose(); + } + } + + public static void main(String[] args) throws Exception { + + ChildWindowProperties obj = new ChildWindowProperties(); + // TestCase1: When Parent is Dialog, Child is Window + obj.testChildPropertiesWithDialogAsParent(); + // TestCase2: When Parent is Frame, chis is Window + obj.testChildPropertiesWithFrameAsParent(); + obj.dispose(); + } + +}