jdk/test/javax/swing/JInternalFrame/8075314/bug8075314.java
changeset 29892 2552120a1589
child 46151 5fa789776f7d
equal deleted inserted replaced
29891:b3c4fa489595 29892:2552120a1589
       
     1 /*
       
     2  * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20  * or visit www.oracle.com if you need additional information or have any
       
    21  * questions.
       
    22  */
       
    23 
       
    24 /* @test
       
    25    @bug 8075314
       
    26    @summary All the InternalFrames will be maximized after maximizing only one
       
    27    of the InternalFrame with the special options "-client -Xmixed
       
    28    -Dswing.defaultlaf=com.sun.java.swing.plaf.windows.WindowsLookAndFeel".
       
    29    @author Semyon Sadetsky
       
    30   */
       
    31 
       
    32 
       
    33 import javax.swing.*;
       
    34 import java.beans.PropertyVetoException;
       
    35 
       
    36 public class bug8075314 {
       
    37 
       
    38 
       
    39     private static JFrame frame;
       
    40     private static JInternalFrame frame1;
       
    41     private static JInternalFrame frame2;
       
    42 
       
    43     public static void main(String[] args) throws Exception {
       
    44         for (UIManager.LookAndFeelInfo lookAndFeelInfo : UIManager
       
    45                 .getInstalledLookAndFeels()) {
       
    46             UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());
       
    47             try {
       
    48                 SwingUtilities.invokeAndWait(new Runnable() {
       
    49                     public void run() {
       
    50                         frame = new JFrame();
       
    51                         frame.setUndecorated(true);
       
    52                         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       
    53                         setup(frame);
       
    54                     }
       
    55                 });
       
    56 
       
    57                 SwingUtilities.invokeAndWait(new Runnable() {
       
    58                     @Override
       
    59                     public void run() {
       
    60                         try {
       
    61                             frame1.setMaximum(true);
       
    62                             frame1.setClosed(true);
       
    63                             if (frame2.isMaximum()) {
       
    64                                 throw new RuntimeException(
       
    65                                         "Frame2 is maximized!");
       
    66                             }
       
    67                         } catch (PropertyVetoException e) {
       
    68                             throw new RuntimeException(e);
       
    69                         }
       
    70 
       
    71                     }
       
    72                 });
       
    73             } finally {
       
    74                 frame.dispose();
       
    75             }
       
    76         }
       
    77         System.out.println("ok");
       
    78     }
       
    79 
       
    80     private static void setup(JFrame frame) {
       
    81         JDesktopPane desktop = new JDesktopPane();
       
    82         frame.setContentPane(desktop);
       
    83 
       
    84         frame1 = new JInternalFrame("1", true, true, true, true);
       
    85         frame1.setBounds(40, 40, 300, 200);
       
    86         frame1.setVisible(true);
       
    87         desktop.add(frame1);
       
    88         frame2 = new JInternalFrame("2", true, true, true, true);
       
    89         frame2.setBounds(20, 20, 300, 200);
       
    90         frame2.setVisible(true);
       
    91         desktop.add(frame2);
       
    92 
       
    93         frame.setSize(500, 400);
       
    94         frame.setVisible(true);
       
    95     }
       
    96 }