Path: blob/master/test/jdk/javax/swing/JInternalFrame/5066752/bug5066752.java
41153 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@key headful25@bug 506675226@summary Transparent JDesktopPane impossible because isOpaque() returns true27@author mb50250: area=JDesktopPane28@library ../../regtesthelpers29@build Util30@run main bug506675231*/3233import java.awt.*;34import javax.swing.*;3536public class bug506675237{38private static JFrame frame;3940public static void main(String[] args) throws Exception {41try {42Robot r = new Robot();43SwingUtilities.invokeAndWait(new Runnable() {44public void run() {45createAndShowGUI();46}47});48r.waitForIdle();4950r.delay(600);5152Point p = Util.getCenterPoint(frame);53Color color = r.getPixelColor((int) p.getX(), (int) p.getY());54if (!color.equals(Color.RED)) {55throw new Exception("Test failed: JDesktopPane isn't transparent. Expected color is (red color): " + Color.RED + ", actual color is: " + color);56}57} finally {58if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());59}60}6162private static void createAndShowGUI() {63frame = new JFrame();6465frame.setLayout(new BorderLayout());66frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);6768JPanel panel = new JPanel();69panel.setLayout(new BorderLayout());70panel.setBackground(Color.RED);71frame.add(panel, BorderLayout.CENTER);7273JDesktopPane dp = new JDesktopPane();74dp.setOpaque(false);75panel.add(dp, BorderLayout.CENTER);7677frame.setBounds(200, 200, 300, 200);78frame.setVisible(true);79}80}818283