Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/ShapedTranslucentPerPixelTranslucentGradient.java
38853 views
/*1* Copyright (c) 2010, 2014, 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*/2223import java.awt.*;2425/*26* @test27* @summary Check if shaped, translucent and per-pixel translucent window is28* dragged and resized by mouse correctly.29* Test Description: Check if PERPIXEL_TRANSLUCENT, TRANSLUCENT and30* PERPIXEL_TRANSPARENT translucency types are supported on the current31* platform. Proceed if they are supported. Create a window with some32* components in it, make window undecorated, apply shape in componentResized33* listener. The shape should match the window size; apply opacity of 0.7,34* apply translucent background of 0 and have a gradient painted as35* background from fully-transparent to fully-opaque in componentResized36* listener. Drag and resize the window using AWT Robot and verify that37* shape and translucency are correctly applied with pixels checking. Make38* the window appear on top of a known background. Repeat this for JWindow,39* JDialog, JFrame.40* Expected Result: If PERPIXEL_TRANSLUCENT, TRANSLUCENT and PERPIXEL_TRANSPARENT41* translucency types are supported, the window should appear as specified42* with the expected shape and translucency. Window background should have43* translucent gradient in parts that are not clipped by shape, all the44* controls should be equally translucent.45* @author mrkam46* @library ../../../../lib/testlibrary47* @build Common ExtendedRobot48* @run main ShapedTranslucentPerPixelTranslucentGradient49*/5051public class ShapedTranslucentPerPixelTranslucentGradient extends Common {5253public static void main(String[] ignored) throws Exception {54if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSLUCENT)55&& checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT)56&& checkTranslucencyMode(GraphicsDevice.WindowTranslucency.TRANSLUCENT))57for (Class<Window> windowClass: WINDOWS_TO_TEST)58new ShapedTranslucentPerPixelTranslucentGradient(windowClass).doTest();59}6061public ShapedTranslucentPerPixelTranslucentGradient(Class windowClass) throws Exception {62super(windowClass, 0.7f, 0f, true);63}6465public void doTest() throws Exception {66robot.waitForIdle(delay);67checkDynamic();68}6970@Override71public void applyShape() {72applyDynamicShape();73gradientWidth = window.getWidth();74gradientHeight = window.getHeight();75}76}777879