Path: blob/master/test/jdk/java/awt/Frame/HideMaximized/HideMaximized.java
41153 views
/*1* Copyright (c) 2012, 2016, 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@key headful26@bug 717717327@summary The maximized state shouldn't be reset upon hiding a frame28@author [email protected]: area=awt.toplevel29@run main HideMaximized30*/3132import java.awt.*;3334public class HideMaximized {35public static void main(String[] args) {36if (!Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH)) {37// Nothing to test38return;39}4041// First test a decorated frame42Frame frame = new Frame("test");43test(frame);4445// Now test an undecorated frames46frame = new Frame("undecorated test");47frame.setUndecorated(true);48test(frame);49}5051private static void test(Frame frame) {52frame.setExtendedState(Frame.MAXIMIZED_BOTH);53frame.setVisible(true);5455try { Thread.sleep(1000); } catch (Exception ex) {}5657if (frame.getExtendedState() != Frame.MAXIMIZED_BOTH) {58throw new RuntimeException("The maximized state has not been applied");59}6061// This will hide the frame, and also clean things up for safe exiting62frame.dispose();6364try { Thread.sleep(1000); } catch (Exception ex) {}6566if (frame.getExtendedState() != Frame.MAXIMIZED_BOTH) {67throw new RuntimeException("The maximized state has been reset");68}69}70}717273