Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/swing/JInternalFrame/6726866/bug6726866.java
38854 views
/*1* Copyright (c) 2009, 2013, 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 672686625@summary Repainting artifacts when resizing or dragging JInternalFrames in non-opaque toplevel26@author Alexander Potochkin27@run applet/manual=yesno bug6726866.html28*/2930import javax.swing.*;31import java.awt.*;32import java.lang.reflect.Method;3334public class bug6726866 extends JApplet {3536public void init() {37JFrame frame = new JFrame("bug6726866");38frame.setUndecorated(true);39setWindowNonOpaque(frame);4041JDesktopPane desktop = new JDesktopPane();42desktop.setBackground(Color.GREEN);43JInternalFrame iFrame = new JInternalFrame("Test", true, true, true, true);44iFrame.add(new JLabel("internal Frame"));45iFrame.setBounds(10, 10, 300, 200);46iFrame.setVisible(true);47desktop.add(iFrame);48frame.add(desktop);4950frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);51frame.setSize(400, 400);52frame.setVisible(true);53frame.toFront();54}5556private void setWindowNonOpaque(Window w) {57try {58Class<?> c = Class.forName("com.sun.awt.AWTUtilities");59Method m = c.getMethod("setWindowOpaque", Window.class, boolean.class);60m.invoke(null, w, false);61}62catch (Exception e) {63e.printStackTrace();64}65}66}676869