/* * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @summary [JavaJDK16] CColorPaint throws Exception with Sun2D renderer (creating translucent variants) * @summary com.apple.junit.java.graphics.color */ import junit.framework.*; import javax.swing.*; import java.awt.*; class Scrap extends JFrame { private JDesktopPane desktopPane = new JDesktopPane(); public Scrap() { super(System.getProperty("java.version")); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setContentPane(desktopPane); desktopPane.add(new TransparentFrame(10, 10)); desktopPane.add(new TransparentFrame(100, 100)); } public class TransparentFrame extends JInternalFrame { public TransparentFrame(int positionX, int positionY) { super("A Transparent Frame", true, true, true, false); setSize(400, 300); setLocation(positionX, positionY); // setFocusable(true); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); JPanel panel = new JPanel(); setContentPane(panel); JButton button = new JButton("Test 1"); button.setOpaque(false); button.setVisible(true); panel.add(button); button = new JButton("Test 2"); button.setOpaque(false); button.setVisible(true); panel.add(button); panel.add(new JTextField("abcdefg")); setVisible(true); } public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 0.5f)); super.paintComponent(g2); } } } public class CColorPaint_R4533150 extends TestCase { public void testCColorPaint_R4533150() throws Exception { Scrap instance = new Scrap(); try { instance.setSize(600, 600); instance.setVisible(true); } finally { instance.dispose(); } } public static Test suite() { return new TestSuite(CColorPaint_R4533150.class); } public static void main (String[] args) throws RuntimeException { TestResult tr = junit.textui.TestRunner.run(suite()); if ((tr.errorCount() != 0) || (tr.failureCount() != 0)) { throw new RuntimeException("### FAILED: unexpected JUnit errors or failures."); } } }