1 /* 2 * Copyright (c) 2013, 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 import java.awt.Dialog; 24 import java.awt.Frame; 25 import java.awt.Toolkit; 26 import java.awt.Window; 27 import sun.awt.SunToolkit; 28 /** 29 * @test 30 * @key headful 31 * @bug 7081594 32 * @author Alexander Scherbatiy 33 * @summary Windows owned by an always-on-top window DO NOT automatically become always-on-top 34 * @run main AlwaysOnTopFieldTest 35 */ 36 public class AlwaysOnTopFieldTest { 37 38 public static void main(String[] args) { 39 SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); 40 41 Window window = new Frame("Window 1"); 42 window.setSize(200, 200); 43 window.setAlwaysOnTop(true); 44 window.setVisible(true); 45 toolkit.realSync(); 46 47 Dialog dialog = new Dialog(window, "Owned dialog 1"); 48 dialog.setSize(200, 200); 49 dialog.setLocation(100, 100); 50 dialog.setVisible(true); 51 toolkit.realSync(); 52 53 try { 54 if (!window.isAlwaysOnTop()) { 55 throw new RuntimeException("Window has wrong isAlwaysOnTop value"); 56 } 57 if (!dialog.isAlwaysOnTop()) { 58 throw new RuntimeException("Dialog has wrong isAlwaysOnTop value"); 59 } 60 } finally { 61 window.dispose(); 62 dialog.dispose(); 63 } 64 65 window = new Frame("Window 2"); 66 window.setSize(200, 200); 67 window.setVisible(true); 68 toolkit.realSync(); 69 70 71 dialog = new Dialog(window, "Owned dialog 2"); 72 dialog.setSize(200, 200); 73 dialog.setLocation(100, 100); 74 dialog.setVisible(true); 75 toolkit.realSync(); 76 77 window.setAlwaysOnTop(true); 78 toolkit.realSync(); 79 80 try { 81 if (!window.isAlwaysOnTop()) { 82 throw new RuntimeException("Window has wrong isAlwaysOnTop value"); 83 } 84 if (!dialog.isAlwaysOnTop()) { 85 throw new RuntimeException("Dialog has wrong isAlwaysOnTop value"); 86 } 87 } finally { 88 window.dispose(); 89 dialog.dispose(); 90 } 91 } 92 }