Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/PerPixelTranslucentGradient.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* @bug 803264428* @summary Check if a per-pixel translucent window is dragged and resized by29* mouse correctly30* Test Description: Check if PERPIXEL_TRANSLUCENT translucency type is supported31* on the current platform. Proceed if they are supported. Create a window32* with some components in it, make window undecorated, apply translucent33* background of 0 and have a gradient painted as background from34* fully-transparent to fully-opaque in componentResized listener. Drag and35* resize the window using AWT Robot and verify that translucency is36* correctly applied with pixels checking. Make the window appear on top of37* a known background. Repeat this for JWindow, JDialog, JFrame.38* Expected Result: If PERPIXEL_TRANSLUCENT translucency type is supported,39* the window should appear as specified with the translucency. Only window40* background should be translucent, all the controls should be opaque.41* @author mrkam42* @library ../../../../lib/testlibrary43* @build Common ExtendedRobot44* @run main PerPixelTranslucentGradient45*/4647public class PerPixelTranslucentGradient extends Common {4849public static void main(String[] ignored) throws Exception {50if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSLUCENT))51for (Class<Window> windowClass: WINDOWS_TO_TEST)52new PerPixelTranslucentGradient(windowClass).doTest();53}5455public PerPixelTranslucentGradient(Class windowClass) throws Exception {56super(windowClass, 1.0f, 0f, true);57}5859public void doTest() throws Exception {60robot.waitForIdle(delay);61checkTranslucent();62}6364@Override65public void applyShape() {66gradientWidth = window.getWidth();67gradientHeight = window.getHeight();68}69}707172