1 /* 2 * Copyright (c) 2004, 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 /* 27 * @test 28 * @summary Construct a Undecorated frame with some components and zoom 29 * the frame and bring it back to normal state. 30 * @author Aruna Samji 31 * @library ../../../lib/testlibrary 32 * @build ExtendedRobot 33 * @run main TaskZoomUndFrameRepaint 34 */ 35 36 public class TaskZoomUndFrameRepaint extends Task<GUIZoomFrame> { 37 38 public static void main (String[] args) throws Exception { 39 new TaskZoomUndFrameRepaint(new GUIZoomFrame(), new ExtendedRobot()).runTask(); 40 } 41 42 TaskZoomUndFrameRepaint(GUIZoomFrame gui, ExtendedRobot robot) { 43 super(gui, robot); 44 } 45 46 public void task() throws Exception { 47 gui.frame2.setUndecorated(true); 48 gui.frame2.setVisible(true); 49 gui.frame2.removeAll(); 50 gui.frame2.add(gui.button); 51 gui.frame2.add(gui.textarea); 52 if (gui.frame2.getExtendedState() != Frame.NORMAL) 53 gui.frame2.setExtendedState(Frame.NORMAL); 54 robot.waitForIdle(1000); 55 56 Point buttonOrigin, newbuttonOrigin, buttonCenter; 57 Point textareaOrigin, newtextareaOrigin, textareaCenter; 58 59 //to find the lenght and width of the component originally 60 buttonOrigin = gui.button.getLocationOnScreen(); 61 textareaOrigin = gui.textarea.getLocationOnScreen(); 62 buttonCenter = gui.button.getLocationOnScreen(); 63 buttonCenter.translate(gui.button.getWidth()/2, gui.button.getHeight()/2); 64 textareaCenter = gui.textarea.getLocationOnScreen(); 65 textareaCenter.translate(gui.textarea.getWidth()/2, gui.textarea.getHeight()/2); 66 67 if (Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH)){ 68 //Maximising the Frame fully......... 69 gui.frame2.setExtendedState(Frame.MAXIMIZED_BOTH); 70 robot.waitForIdle(1000); 71 72 //To check whether the bitwise mask for MAXIMIZED_BOTH state is set... 73 if (gui.frame2.getExtendedState() != Frame.MAXIMIZED_BOTH) 74 throw new RuntimeException("The bitwise mask Frame.MAXIMIZED_BOTH " + 75 "is not set when the frame is in MAXIMIZED_BOTH state"); 76 77 //To check whether the Frame is maximized fully.......... 78 if (gui.maxBoth == false) 79 throw new RuntimeException("Frame is not maximized fully"); 80 } 81 82 //Normalising the Frame.... 83 gui.frame2.setExtendedState(Frame.NORMAL); 84 robot.waitForIdle(1000); 85 86 //To check whether the bitwise mask for NORMAL state is set... 87 if (gui.frame2.getExtendedState() != Frame.NORMAL) 88 throw new RuntimeException("The bitwise mask Frame.NORMAL is not set" + 89 " when the frame is in NORMAL state"); 90 91 //To check whether the Frame is normalised programmatically.......... 92 if (! gui.normal) 93 throw new RuntimeException("Frame is not restored to normal"); 94 95 //to find the lenght and width of the component after zommed and back to normal 96 newbuttonOrigin = gui.button.getLocationOnScreen(); 97 newtextareaOrigin = gui.textarea.getLocationOnScreen(); 98 99 if((buttonOrigin.x != newbuttonOrigin.x)&(buttonOrigin.y != newbuttonOrigin.y)) 100 throw new RuntimeException("The button is not positioned back to " + 101 "the original place on the screen after iconified"); 102 103 if((textareaOrigin.x != newtextareaOrigin.x)&(textareaOrigin.y != newtextareaOrigin.y)) 104 throw new RuntimeException("The TextArea is not positioned back to " + 105 "the original place on the screen after iconified"); 106 107 gui.frame2.remove(gui.button); 108 gui.frame2.remove(gui.textarea); 109 robot.waitForIdle(1000); 110 } 111 }