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 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 38 public class ChangeWindowResizabiltyTest { 39 public static void main(String[] args) throws Exception { 40 Robot robot = new Robot(); 41 for(int i = 0; i < 10; i++) { 42 Dialog dialog = new Dialog((Frame) null); 43 Component panel = new Panel(); 44 panel.setPreferredSize(new Dimension(200, 100)); 45 dialog.add(panel); 46 dialog.pack(); 47 dialog.setVisible(true); 48 49 dialog.setResizable(false); 50 robot.waitForIdle(); 51 robot.delay(200); 52 53 System.out.println(panel.getLocationOnScreen()); 54 System.out.println(dialog.getLocationOnScreen()); 55 if (panel.getLocationOnScreen().y < 56 dialog.getLocationOnScreen().y + dialog.getInsets().top) { 57 dialog.dispose(); 58 throw new RuntimeException( 59 "Wrong content position after setResizable(false)"); 60 } 61 62 dialog.setResizable(true); 63 robot.waitForIdle(); 64 robot.delay(200); 65 System.out.println(panel.getLocationOnScreen()); 66 System.out.println(dialog.getLocationOnScreen()); 67 if (panel.getLocationOnScreen().y < 68 dialog.getLocationOnScreen().y + dialog.getInsets().top) { 69 dialog.dispose(); 70 throw new RuntimeException( 71 "Wrong content position after setResizable(true)"); 72 } 73 74 dialog.dispose(); 75 } 76 } 77 }