Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/ShapedPerPixelTranslucentGradient.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 704384528* @summary Check if shaped and per-pixel translucent window is dragged and29* resized by mouse correctly.30* Test Description: Check if PERPIXEL_TRANSLUCENT and PERPIXEL_TRANSPARENT31* translucency types are supported on the current platform. Proceed if32* they are supported. Create a window with some components in it, make33* window undecorated, apply shape in componentResized listener. The shape34* should match the window size; apply translucent background of 0 and have35* a gradient painted as background from fully-transparent to fully-opaque36* in componentResized listener. Drag and resize the window using AWT Robot37* and verify that shape and translucency are correctly applied with pixels38* checking. Make the window appear on top of a known background. Repeat39* this for JWindow, JDialog, JFrame.40* Expected Result: If PERPIXEL_TRANSLUCENT and PERPIXEL_TRANSPARENT translucency41* types are supported, the window should appear as specified with the42* expected shape and translucency. Window background should have43* translucent gradient in parts that are not clipped by shape, all the44* controls should be opaque.45* @author mrkam46* @library ../../../../lib/testlibrary47* @build Common ExtendedRobot48* @run main ShapedPerPixelTranslucentGradient49*/5051public class ShapedPerPixelTranslucentGradient extends Common {5253public static void main(String[] ignored) throws Exception {54if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSLUCENT)55&& checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))56for (Class<Window> windowClass: WINDOWS_TO_TEST)57new ShapedPerPixelTranslucentGradient(windowClass).doTest();58}5960public ShapedPerPixelTranslucentGradient(Class windowClass) throws Exception {61super(windowClass, 1.0f, 0f, true);62}6364public void doTest() throws Exception {65robot.waitForIdle(delay);66checkDynamic();67}6869@Override70public void applyShape() {71applyDynamicShape();72gradientWidth = window.getWidth();73gradientHeight = window.getHeight();74}7576}777879