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