jdk/test/java/awt/Multiscreen/TranslucencyThrowsExceptionWhenFullScreen/TranslucencyThrowsExceptionWhenFullScreen.java
author malenkov
Tue, 11 Sep 2012 10:58:39 +0400
changeset 13773 69665c88db93
parent 6828 3999af3d33de
child 21596 0e3a39f29dbc
permissions -rw-r--r--
7193977: REGRESSION:Java 7's JavaBeans persistence ignoring the "transient" flag on properties Reviewed-by: rupashka
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
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    10
 *
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    11
 * 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
    12
 * 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
    13
 * 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
    14
 * 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
    15
 * accompanied this code).
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    16
 *
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    17
 * 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
    18
 * 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
    19
 * 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
    20
 *
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    21
 * 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
    22
 * 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
    23
 * questions.
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
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    26
/*
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    27
  @test
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    28
  @bug 6838089
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    29
  @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
    30
  @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
    31
  @run main TranslucencyThrowsExceptionWhenFullScreen
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    32
*/
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    33
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    34
import java.awt.*;
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    35
import java.lang.reflect.InvocationTargetException;
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 class TranslucencyThrowsExceptionWhenFullScreen
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    38
{
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    39
    public static void main(String[] args)
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    40
        throws InvocationTargetException, InterruptedException
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    41
    {
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    42
        EventQueue.invokeAndWait(
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    43
            new Runnable(){
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    44
                public void run() {
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    45
                    Frame frame = new Frame();
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    46
                    frame.setBounds(100,100,100,100);
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    47
                    frame.setVisible(true);
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    48
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    49
                    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    50
                    GraphicsDevice[] devices = ge.getScreenDevices();
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    51
                    for (GraphicsDevice device : devices) {
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    52
                        testGraphicsDevice(device, frame);
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    53
                    }
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
                    frame.dispose();
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
    }
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    60
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    61
    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
    62
        device.setFullScreenWindow(frame);
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    63
        try {
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    64
            frame.setOpacity(0.5f);
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    65
            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
    66
        } catch(IllegalComponentStateException e) {
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    67
            device.setFullScreenWindow(null);
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    68
        }
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    69
    }
3999af3d33de 6838089: java.awt.Window.setOpacity() doesn't throw IllegalComponentStateException for two-display conf
dcherepanov
parents:
diff changeset
    70
}