jdk/test/java/awt/Multiscreen/TranslucencyThrowsExceptionWhenFullScreen/TranslucencyThrowsExceptionWhenFullScreen.java
author serb
Tue, 12 Nov 2013 20:24:25 +0400
changeset 21596 0e3a39f29dbc
parent 6828 3999af3d33de
child 23010 6dadb192ad81
permissions -rw-r--r--
8027696: Incorrect copyright header in the tests Reviewed-by: alanb, malenkov, mullan
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6828
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
     1
/*
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
     2
 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
     4
 *
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
21596
0e3a39f29dbc 8027696: Incorrect copyright header in the tests
serb
parents: 6828
diff changeset
     7
 * published by the Free Software Foundation.
6828
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
     8
 *
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    13
 * accompanied this code).
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    14
 *
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    18
 *
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    21
 * questions.
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    22
 */
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    23
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    24
/*
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    25
  @test
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    26
  @bug 6838089
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    27
  @summary Translucent windows should throw exception in FS mode
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    28
  @author dmitry.cherepanov@oracle.com: area=awt-multiscreen
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    29
  @run main TranslucencyThrowsExceptionWhenFullScreen
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    30
*/
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    31
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    32
import java.awt.*;
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    33
import java.lang.reflect.InvocationTargetException;
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    34
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    35
public class TranslucencyThrowsExceptionWhenFullScreen
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    36
{
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    37
    public static void main(String[] args)
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    38
        throws InvocationTargetException, InterruptedException
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    39
    {
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    40
        EventQueue.invokeAndWait(
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    41
            new Runnable(){
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    42
                public void run() {
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    43
                    Frame frame = new Frame();
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    44
                    frame.setBounds(100,100,100,100);
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    45
                    frame.setVisible(true);
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    46
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    47
                    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    48
                    GraphicsDevice[] devices = ge.getScreenDevices();
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    49
                    for (GraphicsDevice device : devices) {
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    50
                        testGraphicsDevice(device, frame);
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    51
                    }
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    52
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    53
                    frame.dispose();
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    54
                }
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    55
            }
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    56
        );
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    57
    }
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    58
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    59
    private static void testGraphicsDevice(GraphicsDevice device, Frame frame) {
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    60
        device.setFullScreenWindow(frame);
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    61
        try {
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    62
            frame.setOpacity(0.5f);
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    63
            throw new RuntimeException("Test fails, there's no exception for device="+device);
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    64
        } catch(IllegalComponentStateException e) {
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    65
            device.setFullScreenWindow(null);
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    66
        }
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    67
    }
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    68
}