1 /* 2 * Copyright (c) 2016, 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 /* @test 25 @key headful 26 @bug 8166897 8167652 27 @summary Some font overlap in the Optionpane dialog. 28 @run main ChangeWindowResizabiltyTest 29 */ 30 31 import java.awt.Component; 32 import java.awt.Dialog; 33 import java.awt.Dimension; 34 import java.awt.Frame; 35 import java.awt.Panel; 36 import java.awt.Robot; 37 import java.awt.Point; 38 39 public class ChangeWindowResizabiltyTest { main(String[] args)40 public static void main(String[] args) throws Exception { 41 Robot robot = new Robot(); 42 for(int i = 0; i < 10; i++) { 43 Dialog dialog = new Dialog((Frame) null); 44 dialog.setLocation(100, 100); 45 Component panel = new Panel(); 46 panel.setPreferredSize(new Dimension(200, 100)); 47 dialog.add(panel); 48 dialog.pack(); 49 dialog.setVisible(true); 50 robot.waitForIdle(); 51 robot.delay(200); 52 53 Point frameLoc = dialog.getLocationOnScreen(); 54 Point contentLoc = panel.getLocationOnScreen(); 55 56 System.out.println("Decor location " + frameLoc); 57 System.out.println("Content location " + contentLoc); 58 59 dialog.setResizable(false); 60 robot.waitForIdle(); 61 robot.delay(200); 62 63 Point l = dialog.getLocationOnScreen(); 64 if (!l.equals(frameLoc)) { 65 dialog.dispose(); 66 throw new RuntimeException("Decorated frame location moved " + 67 "after setResizable(false)" + l); 68 } 69 70 l = panel.getLocationOnScreen(); 71 if (!l.equals(contentLoc)) { 72 dialog.dispose(); 73 throw new RuntimeException("Content location moved after " + 74 "setResizable(false)" + l); 75 } 76 77 if (panel.getLocationOnScreen().y < 78 dialog.getLocationOnScreen().y + dialog.getInsets().top) { 79 dialog.dispose(); 80 throw new RuntimeException( 81 "Wrong content position after setResizable(false)"); 82 } 83 84 dialog.setResizable(true); 85 robot.waitForIdle(); 86 robot.delay(200); 87 88 l = dialog.getLocationOnScreen(); 89 if (!l.equals(frameLoc)) { 90 dialog.dispose(); 91 throw new RuntimeException("Decorated frame location moved " + 92 "after setResizable(true)" + l); 93 } 94 95 l = panel.getLocationOnScreen(); 96 if (!l.equals(contentLoc)) { 97 dialog.dispose(); 98 throw new RuntimeException("Content location moved after " + 99 "setResizable(true)" + l); 100 } 101 if (panel.getLocationOnScreen().y < 102 dialog.getLocationOnScreen().y + dialog.getInsets().top) { 103 dialog.dispose(); 104 throw new RuntimeException( 105 "Wrong content position after setResizable(true)"); 106 } 107 108 dialog.dispose(); 109 } 110 } 111 } 112