Path: blob/master/test/jdk/javax/swing/JInternalFrame/6726866/bug6726866.java
41153 views
/*1* Copyright (c) 2009, 2017, 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*/2223/* @test24@bug 6726866 818661725@summary Repainting artifacts when resizing or dragging JInternalFrames in26non-opaque toplevel27@run applet/manual=yesno bug6726866.html28*/2930import java.awt.Color;31import java.awt.Window;3233import javax.swing.JApplet;34import javax.swing.JDesktopPane;35import javax.swing.JFrame;36import javax.swing.JInternalFrame;37import javax.swing.JLabel;3839public class bug6726866 extends JApplet {4041public void init() {42JFrame frame = new JFrame("bug6726866");43frame.setUndecorated(true);44setWindowNonOpaque(frame);4546JDesktopPane desktop = new JDesktopPane();47desktop.setBackground(Color.GREEN);48JInternalFrame iFrame = new JInternalFrame("Test", true, true, true, true);49iFrame.add(new JLabel("internal Frame"));50iFrame.setBounds(10, 10, 300, 200);51iFrame.setVisible(true);52desktop.add(iFrame);53frame.add(desktop);5455frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);56frame.setSize(400, 400);57frame.setVisible(true);58frame.toFront();59}6061public static void setWindowNonOpaque(Window window) {62Color bg = window.getBackground();63if (bg == null) {64bg = new Color(0, 0, 0, 0);65}66window.setBackground(67new Color(bg.getRed(), bg.getGreen(), bg.getBlue(), 0));68}69}707172