8075314: All the InternalFrames will be maximized after maximizing only one of the InternalFrame with WindowsLookAndFeel
authorssadetsky
Fri, 03 Apr 2015 16:40:34 +0400
changeset 29892 2552120a1589
parent 29891 b3c4fa489595
child 29893 fb1610d0d75a
8075314: All the InternalFrames will be maximized after maximizing only one of the InternalFrame with WindowsLookAndFeel Reviewed-by: serb, alexsch
jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsDesktopManager.java
jdk/test/javax/swing/JInternalFrame/8075314/bug8075314.java
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsDesktopManager.java	Fri Apr 03 12:41:13 2015 +0100
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsDesktopManager.java	Fri Apr 03 16:40:34 2015 +0400
@@ -68,7 +68,7 @@
             if (currentFrame != null && f != currentFrame) {
                 // If the current frame is maximized, transfer that
                 // attribute to the frame being activated.
-                if (currentFrame.isMaximum() &&
+                if (!currentFrame.isClosed() && currentFrame.isMaximum() &&
                     (f.getClientProperty("JInternalFrame.frameType") !=
                     "optionDialog") ) {
                     //Special case.  If key binding was used to select next
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JInternalFrame/8075314/bug8075314.java	Fri Apr 03 16:40:34 2015 +0400
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2015, 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 8075314
+   @summary All the InternalFrames will be maximized after maximizing only one
+   of the InternalFrame with the special options "-client -Xmixed
+   -Dswing.defaultlaf=com.sun.java.swing.plaf.windows.WindowsLookAndFeel".
+   @author Semyon Sadetsky
+  */
+
+
+import javax.swing.*;
+import java.beans.PropertyVetoException;
+
+public class bug8075314 {
+
+
+    private static JFrame frame;
+    private static JInternalFrame frame1;
+    private static JInternalFrame frame2;
+
+    public static void main(String[] args) throws Exception {
+        for (UIManager.LookAndFeelInfo lookAndFeelInfo : UIManager
+                .getInstalledLookAndFeels()) {
+            UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());
+            try {
+                SwingUtilities.invokeAndWait(new Runnable() {
+                    public void run() {
+                        frame = new JFrame();
+                        frame.setUndecorated(true);
+                        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+                        setup(frame);
+                    }
+                });
+
+                SwingUtilities.invokeAndWait(new Runnable() {
+                    @Override
+                    public void run() {
+                        try {
+                            frame1.setMaximum(true);
+                            frame1.setClosed(true);
+                            if (frame2.isMaximum()) {
+                                throw new RuntimeException(
+                                        "Frame2 is maximized!");
+                            }
+                        } catch (PropertyVetoException e) {
+                            throw new RuntimeException(e);
+                        }
+
+                    }
+                });
+            } finally {
+                frame.dispose();
+            }
+        }
+        System.out.println("ok");
+    }
+
+    private static void setup(JFrame frame) {
+        JDesktopPane desktop = new JDesktopPane();
+        frame.setContentPane(desktop);
+
+        frame1 = new JInternalFrame("1", true, true, true, true);
+        frame1.setBounds(40, 40, 300, 200);
+        frame1.setVisible(true);
+        desktop.add(frame1);
+        frame2 = new JInternalFrame("2", true, true, true, true);
+        frame2.setBounds(20, 20, 300, 200);
+        frame2.setVisible(true);
+        desktop.add(frame2);
+
+        frame.setSize(500, 400);
+        frame.setVisible(true);
+    }
+}