jdk/test/javax/swing/JInternalFrame/Test6802868.java
changeset 3345 e095f8b1c3e8
child 3502 821e773cae60
equal deleted inserted replaced
3344:e2acdc658d52 3345:e095f8b1c3e8
       
     1 /*
       
     2  * Copyright 2009 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
       
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
       
    21  * have any questions.
       
    22  */
       
    23 
       
    24 /*
       
    25  * @test
       
    26  * @bug 6802868
       
    27  * @summary JInternalFrame is not maximized when maximized parent frame
       
    28  * @author Alexander Potochkin
       
    29  */
       
    30 
       
    31 import sun.awt.SunToolkit;
       
    32 
       
    33 import java.awt.Dimension;
       
    34 import java.awt.Point;
       
    35 import java.awt.Robot;
       
    36 import java.awt.Toolkit;
       
    37 import java.beans.PropertyVetoException;
       
    38 import javax.swing.JDesktopPane;
       
    39 import javax.swing.JFrame;
       
    40 import javax.swing.JInternalFrame;
       
    41 import javax.swing.SwingUtilities;
       
    42 
       
    43 public class Test6802868 {
       
    44     static JInternalFrame jif;
       
    45     static JFrame frame;
       
    46     static Dimension size;
       
    47     static Point location;
       
    48 
       
    49     public static void main(String[] args) throws Exception {
       
    50         Robot robot = new Robot();
       
    51         robot.setAutoDelay(20);
       
    52         SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
       
    53 
       
    54         SwingUtilities.invokeAndWait(new Runnable() {
       
    55             public void run() {
       
    56                 frame = new JFrame();
       
    57                 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       
    58 
       
    59                 JDesktopPane jdp = new JDesktopPane();
       
    60                 frame.getContentPane().add(jdp);
       
    61 
       
    62                 jif = new JInternalFrame("Title", true, true, true, true);
       
    63                 jdp.add(jif);
       
    64                 jif.setVisible(true);
       
    65 
       
    66                 frame.setSize(200, 200);
       
    67                 frame.setLocationRelativeTo(null);
       
    68                 frame.setVisible(true);
       
    69 
       
    70                 try {
       
    71                     jif.setMaximum(true);
       
    72                 } catch (Exception e) {
       
    73                     e.printStackTrace();
       
    74                 }
       
    75             }
       
    76         });
       
    77         toolkit.realSync();
       
    78         SwingUtilities.invokeAndWait(new Runnable() {
       
    79             public void run() {
       
    80                 size = jif.getSize();
       
    81                 frame.setSize(300, 300);
       
    82             }
       
    83         });
       
    84         toolkit.realSync();
       
    85         SwingUtilities.invokeAndWait(new Runnable() {
       
    86             public void run() {
       
    87                 if (jif.getSize().equals(size)) {
       
    88                     throw new RuntimeException("InternalFrame hasn't changed its size");
       
    89                 }
       
    90                 try {
       
    91                     jif.setIcon(true);
       
    92                 } catch (PropertyVetoException e) {
       
    93                     e.printStackTrace();
       
    94                 }
       
    95                 location = jif.getDesktopIcon().getLocation();
       
    96                 frame.setSize(400, 400);
       
    97             }
       
    98         });
       
    99         toolkit.realSync();
       
   100         SwingUtilities.invokeAndWait(new Runnable() {
       
   101             public void run() {
       
   102                 if (jif.getDesktopIcon().getLocation().equals(location)) {
       
   103                     throw new RuntimeException("JDesktopIcon hasn't moved");
       
   104                 }
       
   105             }
       
   106         });
       
   107     }
       
   108 }