/* * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import java.awt.*; /* * @test * @summary Construct a Undecorated frame with some components and zoom * the frame and bring it back to normal state. * @author Aruna Samji * @library ../../../lib/testlibrary * @build ExtendedRobot * @run main TaskZoomUndFrameRepaint */ public class TaskZoomUndFrameRepaint extends Task { public static void main (String[] args) throws Exception { new TaskZoomUndFrameRepaint(GUIZoomFrame.class, new ExtendedRobot()).runTask(); } TaskZoomUndFrameRepaint(Class guiClass, ExtendedRobot robot) throws Exception { super(guiClass, robot); } public void task() throws Exception { EventQueue.invokeAndWait(() -> { gui.frame2.setUndecorated(true); gui.frame2.setVisible(true); gui.frame2.removeAll(); gui.frame2.add(gui.button); gui.frame2.add(gui.textarea); if (gui.frame2.getExtendedState() != Frame.NORMAL) gui.frame2.setExtendedState(Frame.NORMAL); }); robot.waitForIdle(1000); Point buttonOrigin, newbuttonOrigin, buttonCenter; Point textareaOrigin, newtextareaOrigin, textareaCenter; //to find the lenght and width of the component originally buttonOrigin = gui.button.getLocationOnScreen(); textareaOrigin = gui.textarea.getLocationOnScreen(); buttonCenter = gui.button.getLocationOnScreen(); buttonCenter.translate(gui.button.getWidth()/2, gui.button.getHeight()/2); textareaCenter = gui.textarea.getLocationOnScreen(); textareaCenter.translate(gui.textarea.getWidth()/2, gui.textarea.getHeight()/2); if (Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH)){ //Maximising the Frame fully......... EventQueue.invokeAndWait(() -> gui.frame2.setExtendedState(Frame.MAXIMIZED_BOTH) ); robot.waitForIdle(1000); //To check whether the bitwise mask for MAXIMIZED_BOTH state is set... if (gui.frame2.getExtendedState() != Frame.MAXIMIZED_BOTH) throw new RuntimeException("The bitwise mask Frame.MAXIMIZED_BOTH " + "is not set when the frame is in MAXIMIZED_BOTH state"); //To check whether the Frame is maximized fully.......... if (gui.maxBoth == false) throw new RuntimeException("Frame is not maximized fully"); } //Normalising the Frame.... EventQueue.invokeAndWait(() -> gui.frame2.setExtendedState(Frame.NORMAL) ); robot.waitForIdle(1000); //To check whether the bitwise mask for NORMAL state is set... if (gui.frame2.getExtendedState() != Frame.NORMAL) throw new RuntimeException("The bitwise mask Frame.NORMAL is not set" + " when the frame is in NORMAL state"); //To check whether the Frame is normalised programmatically.......... if (! gui.normal) throw new RuntimeException("Frame is not restored to normal"); //to find the lenght and width of the component after zommed and back to normal newbuttonOrigin = gui.button.getLocationOnScreen(); newtextareaOrigin = gui.textarea.getLocationOnScreen(); if((buttonOrigin.x != newbuttonOrigin.x)&(buttonOrigin.y != newbuttonOrigin.y)) throw new RuntimeException("The button is not positioned back to " + "the original place on the screen after iconified"); if((textareaOrigin.x != newtextareaOrigin.x)&(textareaOrigin.y != newtextareaOrigin.y)) throw new RuntimeException("The TextArea is not positioned back to " + "the original place on the screen after iconified"); EventQueue.invokeAndWait(() -> { gui.frame2.remove(gui.button); gui.frame2.remove(gui.textarea); }); robot.waitForIdle(1000); } }