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