jdk/test/java/awt/Window/MultiWindowApp/ChildAlwaysOnTopTest.java
author ssadetsky
Tue, 15 Mar 2016 09:18:29 +0300
changeset 36882 9347af61016c
permissions -rw-r--r--
8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios Reviewed-by: serb, azvegint
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36882
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
     1
/*
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
     4
 *
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
     7
 * published by the Free Software Foundation.
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
     8
 *
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    13
 * accompanied this code).
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    14
 *
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    18
 *
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    21
 * questions.
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    22
 */
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    23
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    24
/**
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    25
 * @test @summary setAlwaysOnTop doesn't behave correctly in Linux/Solaris under
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    26
 *                certain scenarios
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    27
 * @bug 8021961
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    28
 * @author Semyon Sadetsky
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    29
 * @run main ChildAlwaysOnTopTest
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    30
 */
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    31
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    32
import javax.swing.*;
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    33
import java.awt.*;
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    34
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    35
public class ChildAlwaysOnTopTest {
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    36
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    37
    private static Window win1;
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    38
    private static Window win2;
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    39
    private static Point point;
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    40
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    41
    public static void main(String[] args) throws Exception {
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    42
        if( Toolkit.getDefaultToolkit().isAlwaysOnTopSupported() ) {
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    43
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    44
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    45
            test(null);
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    46
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    47
            Window f = new Frame();
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    48
            f.setBackground(Color.darkGray);
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    49
            f.setSize(500, 500);
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    50
            try {
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    51
                test(f);
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    52
            } finally {
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    53
                f.dispose();
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    54
            }
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    55
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    56
            f = new Frame();
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    57
            f.setBackground(Color.darkGray);
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    58
            f.setSize(500, 500);
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    59
            f.setVisible(true);
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    60
            f = new Dialog((Frame)f);
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    61
            try {
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    62
                test(f);
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    63
            } finally {
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    64
                ((Frame)f.getParent()).dispose();
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    65
            }
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    66
        }
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    67
        System.out.println("ok");
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    68
    }
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    69
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    70
    public static void test(Window parent) throws Exception {
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    71
        SwingUtilities.invokeAndWait(new Runnable() {
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    72
            @Override
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    73
            public void run() {
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    74
                win1 = parent == null ? new JDialog() : new JDialog(parent);
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    75
                win1.setName("top");
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    76
                win2 = parent == null ? new JDialog() : new JDialog(parent);
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    77
                win2.setName("behind");
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    78
                win1.setSize(200, 200);
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    79
                Panel panel = new Panel();
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    80
                panel.setBackground(Color.GREEN);
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    81
                win1.add(panel);
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    82
                panel = new Panel();
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    83
                panel.setBackground(Color.RED);
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    84
                win2.add(panel);
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    85
                win1.setAlwaysOnTop(true);
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    86
                win2.setAlwaysOnTop(false);
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    87
                win1.setVisible(true);
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    88
            }
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    89
        });
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    90
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    91
        Robot robot = new Robot();
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    92
        robot.delay(200);
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    93
        robot.waitForIdle();
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    94
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    95
        SwingUtilities.invokeAndWait(new Runnable() {
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    96
            @Override
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    97
            public void run() {
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    98
                point = win1.getLocationOnScreen();
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
    99
                win2.setBounds(win1.getBounds());
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   100
                win2.setVisible(true);
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   101
            }
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   102
        });
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   103
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   104
        robot.delay(200);
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   105
        robot.waitForIdle();
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   106
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   107
        Color color = robot.getPixelColor(point.x + 100, point.y + 100);
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   108
        if(!color.equals(Color.GREEN)) {
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   109
            win1.dispose();
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   110
            win2.dispose();
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   111
            throw new RuntimeException("alawaysOnTop window is sent back by " +
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   112
                    "another child window setVisible(). " + color);
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   113
        }
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   114
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   115
        SwingUtilities.invokeAndWait(new Runnable() {
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   116
            @Override
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   117
            public void run() {
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   118
                win2.toFront();
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   119
                if (parent != null) {
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   120
                    parent.setLocation(win1.getLocation());
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   121
                    parent.toFront();
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   122
                }
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   123
            }
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   124
        });
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   125
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   126
        robot.delay(200);
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   127
        robot.waitForIdle();
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   128
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   129
        color = robot.getPixelColor(point.x + 100, point.y + 100);
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   130
        if(!color.equals(Color.GREEN)) {
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   131
            win1.dispose();
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   132
            win2.dispose();
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   133
            throw new RuntimeException("alawaysOnTop window is sent back by " +
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   134
                    "another child window toFront(). " + color);
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   135
        }
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   136
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   137
        SwingUtilities.invokeAndWait(new Runnable() {
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   138
            @Override
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   139
            public void run() {
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   140
                win1.setAlwaysOnTop(false);
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   141
                if (parent != null) {
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   142
                    parent.setVisible(false);
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   143
                    parent.setVisible(true);
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   144
                }
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   145
                win2.toFront();
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   146
            }
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   147
        });
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   148
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   149
        robot.delay(200);
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   150
        robot.waitForIdle();
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   151
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   152
        color = robot.getPixelColor(point.x + 100, point.y + 100);
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   153
        if(!color.equals(Color.RED)) {
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   154
            throw new RuntimeException("Failed to unset alawaysOnTop " + color);
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   155
        }
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   156
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   157
        win1.dispose();
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   158
        win2.dispose();
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   159
    }
9347af61016c 8021961: setAlwaysOnTop doesn't behave correctly in Linux/Solaris under certain scenarios
ssadetsky
parents:
diff changeset
   160
}