1 /* 2 * Copyright (c) 2007, 2014, 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 import java.awt.*; 25 26 import static jdk.testlibrary.Asserts.assertEquals; 27 import static sun.awt.OSInfo.*; 28 29 /* 30 * @test 31 * @summary When Frame.setExtendedState(Frame.MAXIMIZED_BOTH) 32 * is called for a Frame after been called setMaximizedBounds() with 33 * certain value, Frame bounds must equal to this value. 34 * 35 * @library ../../../../lib/testlibrary 36 * @build ExtendedRobot jdk.testlibrary.Asserts 37 * @run main SetMaximizedBounds 38 */ 39 40 public class SetMaximizedBounds { 41 42 Frame testFrame; 43 Rectangle bound; 44 boolean supported; 45 ExtendedRobot robot; 46 static Rectangle max = new Rectangle(100,100,400,400); 47 48 public void doTest() throws Exception { 49 robot = new ExtendedRobot(); 50 51 EventQueue.invokeAndWait( () -> { 52 testFrame = new Frame( "TestFrame "); 53 testFrame.setLayout(new FlowLayout()); 54 55 if (Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH)) { 56 supported = true; 57 testFrame.setMaximizedBounds(max); 58 } else { 59 supported = false; 60 } 61 62 testFrame.setSize(200, 200); 63 testFrame.setVisible(true); 64 }); 65 66 robot.waitForIdle(2000); 67 if (supported) { 68 EventQueue.invokeAndWait( () -> { 69 testFrame.setExtendedState(Frame.MAXIMIZED_BOTH); 70 }); 71 robot.waitForIdle(2000); 72 bound = testFrame.getBounds(); 73 assertEquals(bound, max, 74 "The bounds of the Frame equal to what" 75 + " is specified when the frame is in Frame.MAXIMIZED_BOTH state"); 76 } else { 77 System.out.println("Frame.MAXIMIZED_BOTH not supported"); 78 } 79 } 80 81 public static void main(String[] args) throws Exception { 82 if (getOSType() == OSType.WINDOWS) 83 new SetMaximizedBounds().doTest(); 84 else 85 System.out.println("Only Windows platform supported"); 86 } 87 }