Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentPerPixelTranslucentGradient.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 a per-pixel translucent and translucent window is dragged28* and resized by mouse correctly29* Test Description: Check if PERPIXEL_TRANSLUCENT and TRANSLUCENT translucency30* types are supported on the current platform. Proceed if they are supported.31* Create a window with some components in it, make window undecorated, apply32* opacity of 0.7, apply translucent background of 0 and have a gradient33* painted as background from fully-transparent to fully-opaque in34* componentResized listener. Drag and resize the window using AWT Robot and35* verify that translucency is correctly applied with pixels checking. Make36* the window appear on top of a known background. Repeat this for specified37* JWindow, JDialog, JFrame.38* Expected Result: If PERPIXEL_TRANSLUCENT and TRANSLUCENT translucency types39* are supported, the window should appear as specified with the translucency.40* Both window background and all the controls should be translucent but41* background should have a gradient in translucency while controls - not.42* @author mrkam43* @library ../../../../lib/testlibrary44* @build Common ExtendedRobot45* @run main TranslucentPerPixelTranslucentGradient46*/4748public class TranslucentPerPixelTranslucentGradient extends Common {4950public static void main(String[] ignored) throws Exception {51if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSLUCENT)52&& checkTranslucencyMode(GraphicsDevice.WindowTranslucency.TRANSLUCENT))53for (Class<Window> windowClass: WINDOWS_TO_TEST)54new TranslucentPerPixelTranslucentGradient(windowClass).doTest();55}5657public TranslucentPerPixelTranslucentGradient(Class windowClass) throws Exception {58super(windowClass, 0.7f, 0f, true);59}6061public void doTest() throws Exception {62robot.waitForIdle(delay);63checkTranslucent();64}6566@Override67public void applyShape() {68gradientWidth = window.getWidth();69gradientHeight = window.getHeight();70}71}727374