Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/awt/Frame/HideMaximized/HideMaximized.java
38828 views
/*1* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24@test25@bug 717717326@summary The maximized state shouldn't be reset upon hiding a frame27@author [email protected]: area=awt.toplevel28@run main HideMaximized29*/3031import java.awt.*;3233public class HideMaximized {34public static void main(String[] args) {35if (!Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH)) {36// Nothing to test37return;38}3940// First test a decorated frame41Frame frame = new Frame("test");42test(frame);4344// Now test an undecorated frames45frame = new Frame("undecorated test");46frame.setUndecorated(true);47test(frame);48}4950private static void test(Frame frame) {51frame.setExtendedState(Frame.MAXIMIZED_BOTH);52frame.setVisible(true);5354try { Thread.sleep(1000); } catch (Exception ex) {}5556if (frame.getExtendedState() != Frame.MAXIMIZED_BOTH) {57throw new RuntimeException("The maximized state has not been applied");58}5960// This will hide the frame, and also clean things up for safe exiting61frame.dispose();6263try { Thread.sleep(1000); } catch (Exception ex) {}6465if (frame.getExtendedState() != Frame.MAXIMIZED_BOTH) {66throw new RuntimeException("The maximized state has been reset");67}68}69}707172