Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/swing/JInternalFrame/5066752/bug5066752.java
38854 views
/*1* Copyright (c) 2012, 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*/22/*23@test24@bug 506675225@summary Transparent JDesktopPane impossible because isOpaque() returns true26@author mb50250: area=JDesktopPane27@library ../../regtesthelpers28@build Util29@run main bug506675230*/3132import java.awt.*;33import javax.swing.*;3435public class bug506675236{37private static JFrame frame;3839public static void main(String[] args) throws Exception {40Robot r = new Robot();41SwingUtilities.invokeAndWait(new Runnable() {42public void run() {43createAndShowGUI();44}45});46r.waitForIdle();4748r.delay(600);4950Point p = Util.getCenterPoint(frame);51Color color = r.getPixelColor((int) p.getX(), (int) p.getY());52if (!color.equals(Color.RED)) {53throw new Exception("Test failed: JDesktopPane isn't transparent. Expected color is (red color): " + Color.RED + ", actual color is: " + color);54}55}5657private static void createAndShowGUI() {58frame = new JFrame();5960frame.setLayout(new BorderLayout());61frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);6263JPanel panel = new JPanel();64panel.setLayout(new BorderLayout());65panel.setBackground(Color.RED);66frame.add(panel, BorderLayout.CENTER);6768JDesktopPane dp = new JDesktopPane();69dp.setOpaque(false);70panel.add(dp, BorderLayout.CENTER);7172frame.setBounds(200, 200, 300, 200);73frame.setVisible(true);74}75}767778