Path: blob/master/test/jdk/java/awt/Dialog/SiblingChildOrder/SiblingChildOrderTest.java
41153 views
/*1* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/**24* @test25* @bug 8190230 819636026* @summary [macosx] Order of overlapping of modal dialogs is wrong27* @key headful28* @run main SiblingChildOrderTest29*/3031import java.awt.Color;32import java.awt.Robot;33import javax.swing.JDialog;34import javax.swing.JFrame;35import javax.swing.SwingUtilities;3637public class SiblingChildOrderTest38{39static Color[] colors = new Color[]{Color.RED, Color.GREEN, Color.BLUE, Color.YELLOW};40static int[] x = new int[]{200, 150, 100, 50};41static int[] y = new int[]{200, 150, 100, 50};42static JDialog[] dlgs = new JDialog[4];43private static JFrame frame;4445public static void main(String args[]) throws Exception {46SwingUtilities.invokeAndWait(() -> {47frame = new JFrame("FRAME");48frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);49frame.setUndecorated(true);50frame.setBounds(50,50, 400, 400);51frame.setVisible(true);52});5354for (int i = 0; i < colors.length; i++) {55int finalI = i;56SwingUtilities.invokeLater(() -> {57dlgs[finalI] = new JDialog(frame, "DLG " + finalI, true);58dlgs[finalI].getContentPane().setBackground(colors[finalI]);59dlgs[finalI].setBounds(x[finalI], y[finalI], 200, 200);60dlgs[finalI].setUndecorated(true);61dlgs[finalI].setVisible(true);62});63}6465Robot robot = new Robot();66robot.waitForIdle();67robot.delay(1000);6869for (int i = 0; i < colors.length; i++) {70Color c = robot.getPixelColor(x[i] + 190, y[i] + 190);71if (!c.equals(colors[i])) {72throw new RuntimeException("Expected " + colors[i] + " got " + c);73}74}7576for (int i = 0; i < colors.length; i++) {77SwingUtilities.invokeLater(dlgs[i]::dispose);78}79SwingUtilities.invokeLater(frame::dispose);80}81}828384