8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
authordermashov
Tue, 26 Aug 2014 15:04:49 +0400
changeset 26601 2713482c0fd3
parent 26358 abfc0d4035bf
child 26602 7627c665ee0e
8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK Reviewed-by: alexsch
jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/Common.java
jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/PerPixelTranslucent.java
jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/PerPixelTranslucentCanvas.java
jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/PerPixelTranslucentGradient.java
jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/PerPixelTranslucentSwing.java
jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/SetShapeAndClickSwing.java
jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/ShapedPerPixelTranslucentGradient.java
jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/ShapedTranslucentPerPixelTranslucentGradient.java
jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentJComboBox.java
jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentPerPixelTranslucentGradient.java
jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentWindowClickSwing.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/Common.java	Tue Aug 26 15:04:49 2014 +0400
@@ -0,0 +1,417 @@
+/*
+ * Copyright (c) 2014, 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.
+ */
+
+import javax.swing.*;
+import javax.swing.border.EmptyBorder;
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.geom.Area;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.security.SecureRandom;
+
+public abstract class Common {
+
+    ExtendedRobot robot;
+    Class<? extends JFrame> windowClass;
+    JFrame background;
+    BufferedImage foreground;
+    Window window;
+    volatile boolean gradientBackgroundEnabled = false;
+    volatile int gradientWidth = 255;
+    volatile int gradientHeight = 255;
+
+    float opacity = 1.0f;
+    float perPixelTranslucency = 1.0f;
+    static Color BG_COLOR = Color.BLUE;
+    static Color FG_COLOR = Color.RED;
+    static final int delay = 1000;
+    static final SecureRandom random = new SecureRandom();
+    static final int dl = 100;
+    static final Class[] WINDOWS_TO_TEST = { JWindow.class, JFrame.class, JDialog.class };
+
+    volatile int clicked;
+
+    public Common(Class windowClass, float opacity, float perPixelTranslucency, boolean gradient) throws Exception {
+        this.gradientBackgroundEnabled = gradient;
+        this.perPixelTranslucency = perPixelTranslucency;
+        this.opacity = opacity;
+        robot = new ExtendedRobot();
+        this.windowClass = windowClass;
+        EventQueue.invokeAndWait(this::initBackgroundFrame);
+        EventQueue.invokeAndWait(this::initGUI);
+    }
+
+    public Common(Class windowClass) throws Exception {
+        this(windowClass, 1.0f, 1.0f, false);
+    }
+
+    public Common(Class windowClass, boolean gradient) throws Exception {
+        this(windowClass, 1.0f, 1.0f, gradient);
+    }
+
+    public abstract void doTest() throws Exception;
+
+    public void dispose() {
+        window.dispose();
+        background.dispose();
+    }
+
+    public void applyShape() {};
+
+    public void applyDynamicShape() {
+        final Area a = new Area();
+        Dimension size = window.getSize();
+        for (int x = 0; x < 3; x++) {
+            for (int y = 0; y < 3; y++) {
+                a.add(new Area(new Rectangle2D.Double(
+                        x * size.getWidth() / 17*6, y * size.getHeight() / 17*6,
+                        size.getWidth() / 17*5, size.getHeight() / 17*5)));
+            }
+        }
+        window.setShape(a);
+    }
+
+    public BufferedImage getForegroundWindow() throws Exception {
+        final BufferedImage f[] = new BufferedImage[1];
+        EventQueue.invokeAndWait( () -> {
+            f[0] = new BufferedImage(window.getWidth(),
+                    window.getHeight(), BufferedImage.TYPE_INT_RGB);
+            window.printAll(f[0].createGraphics());
+        });
+        robot.waitForIdle(delay);
+        return f[0];
+    }
+
+    public static boolean checkTranslucencyMode(GraphicsDevice.WindowTranslucency mode) {
+
+        if (!GraphicsEnvironment
+                .getLocalGraphicsEnvironment()
+                .getDefaultScreenDevice()
+                .isWindowTranslucencySupported(mode)){
+            System.out.println(mode+" translucency mode isn't supported");
+            return false;
+        } else {
+            return true;
+        }
+
+    }
+
+    public void applyAppDragNResizeSupport() {
+        MouseAdapter m = new MouseAdapter() {
+
+            private Point dragOrigin = null;
+            private Dimension origSize = null;
+            private Point origLoc = null;
+            private boolean left = false;
+            private boolean top = false;
+            private boolean bottom = false;
+            private boolean right = false;
+
+            public void mousePressed(MouseEvent e) {
+                dragOrigin = e.getLocationOnScreen();
+                origSize = window.getSize();
+                origLoc = window.getLocationOnScreen();
+                right = (origLoc.x + window.getWidth() - dragOrigin.x) < 5;
+                left = !right && dragOrigin.x - origLoc.x < 5;
+                bottom = (origLoc.y + window.getHeight() - dragOrigin.y) < 5;
+                top = !bottom && dragOrigin.y - origLoc.y < 5;
+            }
+
+            public void mouseReleased(MouseEvent e) { resize(e); }
+            public void mouseDragged(MouseEvent e) { resize(e); }
+
+            void resize(MouseEvent e) {
+                Point dragDelta = e.getLocationOnScreen();
+                dragDelta.translate(-dragOrigin.x, -dragOrigin.y);
+                Point newLoc = new Point(origLoc);
+                newLoc.translate(dragDelta.x, dragDelta.y);
+                Dimension newSize = new Dimension(origSize);
+                if (left || right) {
+                    newSize.width += right ? dragDelta.x : -dragDelta.x;
+                }
+                if (top || bottom) {
+                    newSize.height += bottom ? dragDelta.y : -dragDelta.y;
+                }
+                if (right || (top || bottom) && !left) {
+                    newLoc.x = origLoc.x;
+                }
+                if (bottom || (left || right) && !top) {
+                    newLoc.y = origLoc.y;
+                }
+                window.setBounds(newLoc.x, newLoc.y, newSize.width, newSize.height);
+            }
+        };
+        for (Component comp : window.getComponents()) {
+            comp.addMouseListener(m);
+            comp.addMouseMotionListener(m);
+        }
+
+        window.addMouseListener(m);
+        window.addMouseMotionListener(m);
+    }
+
+    public void checkTranslucentShape() throws Exception {
+        foreground = getForegroundWindow();
+        Point[] points = new Point[4];
+
+        Dimension size = window.getSize();
+        Point location = window.getLocationOnScreen();
+
+        points[0] = new Point(20, 20);
+        points[1] = new Point(20, size.height-20);
+        points[2] = new Point(size.width-20, 20);
+        points[3] = new Point(size.width-20, size.height-20);
+
+        for (Point p : points){
+            p.translate(location.x, location.y);
+            Color actual = robot.getPixelColor(p.x, p.y);
+            if (actual.equals(BG_COLOR)|| actual.equals(FG_COLOR))
+                throw new RuntimeException("Error in point "+p+": "+actual+" equals to foreground or background color");
+            else
+                System.out.println("OK with foreground point "+p);
+        }
+    }
+
+    public void checkDynamicShape() throws Exception {
+        Point[] points = new Point[4];
+
+        Dimension size = window.getSize();
+
+        int blockSizeX = (int) (size.getWidth() / 17);
+        int blockSizeY = (int) (size.getHeight() / 17);
+
+        // background
+        points[0] = new Point((int) (blockSizeX * 5.5), (int) (blockSizeY * 5.5));
+        points[1] = new Point((int) (size.getWidth() - blockSizeX * 5.5), (int) (size.getHeight() - blockSizeY * 5.5));
+        points[2] = new Point((int) (blockSizeX * 5.5), (int) (size.getHeight() - blockSizeY * 5.5));
+        points[3] = new Point((int) (size.getWidth() - blockSizeX * 5.5), (int) (blockSizeY * 5.5));
+        checkShape(points, true);
+
+        // foreground
+        if (opacity < 1.0f){
+            checkTranslucentShape();
+        } else {
+            points[0] = new Point(3 * blockSizeX, 3 * blockSizeY);
+            points[1] = new Point(14 * blockSizeX, 14 * blockSizeY);
+            points[2] = new Point(3 * blockSizeX, 14 * blockSizeY);
+            points[3] = new Point(14 * blockSizeX, 3 * blockSizeY);
+            checkShape(points, false);
+        }
+    }
+
+    public void checkShape(Point[] points, boolean areBackgroundPoints) throws Exception {
+
+        Point location = window.getLocationOnScreen();
+
+        for (Point p : points) {
+            p.translate(location.x, location.y);
+            Color pixel = robot.getPixelColor(p.x, p.y);
+            if (areBackgroundPoints) {
+                if (pixel.getRed() != 0
+                    || pixel.getGreen() != 0 )
+                    throw new RuntimeException("Background point " + p +
+                            " color " + pixel +
+                            " does not equal to background color " + BG_COLOR);
+                else
+                    System.out.println("OK with background point " + p);
+            } else {
+                if (pixel.equals(BG_COLOR))
+                    throw new RuntimeException("Foreground point " + p +
+                            " color " + pixel +
+                            " equals to background color " + BG_COLOR);
+                else
+                    System.out.println("OK with foreground point " + p);
+            }
+        }
+    }
+
+    public void initBackgroundFrame() {
+        background = new JFrame();
+        background.setUndecorated(true);
+        background.getContentPane().setBackground(BG_COLOR);
+        background.setSize(500, 500);
+        background.setLocation(dl, dl);
+        background.setVisible(true);
+    }
+
+    public void initGUI() {
+        Container contentPane;
+        if (windowClass.equals(Frame.class)) {
+            window = new JFrame();
+            ((JFrame) window).setUndecorated(true);
+            contentPane = ((JFrame) window).getContentPane();
+        } else  if (windowClass.equals(Dialog.class)) {
+            window = new JDialog(background);
+            ((JDialog) window).setUndecorated(true);
+            contentPane = ((JDialog) window).getContentPane();
+        } else {
+            window = new JWindow(background);
+            contentPane = ((JWindow) window).getContentPane();
+        }
+
+        if (perPixelTranslucency < 1.0f) {
+            contentPane.setBackground(colorWithOpacity(FG_COLOR, perPixelTranslucency));
+            window.setBackground(colorWithOpacity(FG_COLOR, perPixelTranslucency));
+        } else {
+            contentPane.setBackground(FG_COLOR);
+            window.setBackground(FG_COLOR);
+        }
+
+        window.setLocation(2 * dl, 2 * dl);
+        window.setSize(255, 255);
+        window.setPreferredSize(new Dimension(255, 255));
+        createSwingComponents();
+        if (opacity < 1.0f)
+            window.setOpacity(opacity);
+
+        window.addComponentListener(new ComponentAdapter() {
+            @Override
+            public void componentResized(ComponentEvent e) {
+                applyShape();
+            }
+        });
+        applyShape();
+        window.setVisible(true);
+        applyAppDragNResizeSupport();
+        window.toFront();
+    }
+
+    public void createSwingComponents() {
+        Container contentPane;
+        if (gradientBackgroundEnabled) {
+            JPanel jPanel = new JPanel() {
+                @Override
+                protected void paintComponent(Graphics g) {
+                    if (g instanceof Graphics2D) {
+                        Color background = Color.RED;
+                        Paint p = new GradientPaint(0.0f, 0.0f, colorWithOpacity(background, 0),
+                                0.0f, gradientHeight - 3, colorWithOpacity(background, 1), true);
+                        Graphics2D g2d = (Graphics2D) g;
+                        g2d.setPaint(p);
+                        g2d.fillRect(0, 3, gradientWidth, gradientHeight - 3);
+                    } else {
+                        super.paintComponent(g);
+                    }
+                }
+            };
+            jPanel.setBorder(new EmptyBorder(15, 5, 5, 5));
+            jPanel.setOpaque(false);
+
+            contentPane = jPanel;
+
+            RootPaneContainer.class.cast(window).setContentPane(contentPane);
+        } else {
+            contentPane = RootPaneContainer.class.cast(window).getContentPane();
+        }
+        contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
+
+        JButton button = new JButton("JButton");
+        window.add(button);
+
+        JTextArea textArea = new JTextArea("JTextArea");
+        window.add(textArea);
+
+        JCheckBox checkbox = new JCheckBox("JCheckBox");
+        checkbox.setOpaque(false);
+        window.add(checkbox);
+
+        JComboBox comboBox = new JComboBox(new String[]{"JComboBox", "Some item"});
+        window.add(comboBox);
+
+        JLabel label = new JLabel("JLabel");
+        window.add(label);
+
+        JTextField textField = new JTextField("JTextField");
+        window.add(textField);
+
+        JPanel panel = new JPanel();
+        panel.setOpaque(false);
+        window.add(panel);
+
+        JComboBox comboBox2 = new JComboBox(new String[]{"JComboBox2", "Another item"});
+        window.add(comboBox2);
+
+        JRadioButton radioButton = new JRadioButton("JRadioButton");
+        radioButton.setOpaque(false);
+        window.add(radioButton);
+    }
+
+    Color colorWithOpacity(Color color, float opacity) {
+        return new Color(color.getColorSpace(), color.getColorComponents(null), opacity);
+    }
+
+    public void checkTranslucent() throws Exception {
+        checkTranslucentShape();
+
+        // Drag
+        Point location = window.getLocationOnScreen();
+        robot.dragAndDrop(location.x + 30, location.y + 5, location.x + dl + random.nextInt(dl), location.y + random.nextInt(dl));
+        robot.waitForIdle(delay);
+        checkTranslucentShape();
+
+        // Resize
+        location = window.getLocationOnScreen();
+        robot.dragAndDrop(location.x + 4, location.y + 4, location.x + random.nextInt(2*dl)-dl, location.y + random.nextInt(2*dl)-dl);
+        robot.waitForIdle(delay);
+        checkTranslucentShape();
+
+        EventQueue.invokeAndWait(this::dispose);
+    }
+
+    public void checkDynamic() throws Exception {
+        checkDynamicShape();
+
+        // Drag
+        Point location = window.getLocationOnScreen();
+        robot.dragAndDrop(location.x + 30, location.y + 5, location.x + dl + random.nextInt(dl), location.y + random.nextInt(dl));
+        robot.waitForIdle(delay);
+        checkDynamicShape();
+
+        // Resize
+        location = window.getLocationOnScreen();
+        robot.dragAndDrop(location.x + 4, location.y + 4, location.x + random.nextInt(2*dl)-dl, location.y + random.nextInt(2*dl)-dl);
+        robot.waitForIdle(delay);
+        checkDynamicShape();
+
+        EventQueue.invokeAndWait(this::dispose);
+    }
+
+    void checkClick(int x, int y, int flag) throws Exception {
+
+        System.out.println("Trying to click point " + x + ", " + y + ", looking for " + flag + " flag to trigger.");
+
+        clicked = 0;
+        robot.mouseMove(x, y);
+        robot.click();
+
+        for (int i = 0; i < 100; i++)
+            if ((clicked & (1 << flag)) == 0)
+                robot.delay(50);
+            else
+                break;
+
+        if ((clicked & (1 << flag)) == 0)
+            throw new RuntimeException("FAIL: Flag " + flag + " is not triggered for point " + x + ", " + y + "!");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/PerPixelTranslucent.java	Tue Aug 26 15:04:49 2014 +0400
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2010, 2014, 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.
+ */
+
+import java.awt.*;
+
+/*
+ * @test
+ * @summary Check if a per-pixel translucent window is dragged and resized
+ *          by mouse correctly.
+ * Test Description: Check if PERPIXEL_TRANSLUCENT translucency type is supported
+ *      on the current platform. Proceed if they are supported. Create a window
+ *      with some components in it, make window undecorated, apply translucent
+ *      background of 0.5. Drag and resize the window using AWT Robot and verify
+ *      that translucency is correctly applied with pixels checking. Make the
+ *      window appear on top of a known background. Repeat this for JWindow,
+ *      JDialog, JFrame.
+ * Expected Result: If PERPIXEL_TRANSLUCENT translucency type is supported, the
+ *      window should appear with the translucency. Only window background
+ *      should be translucent, all the controls should be opaque.
+ * @author mrkam
+ * @library ../../../../lib/testlibrary
+ * @build Common ExtendedRobot
+ * @run main PerPixelTranslucent
+ */
+
+public class PerPixelTranslucent extends Common {
+
+    public static void main(String[] ignored) throws Exception {
+        if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSLUCENT))
+            for (Class<Window> windowClass: WINDOWS_TO_TEST)
+                new PerPixelTranslucent(windowClass).doTest();
+    }
+
+    public PerPixelTranslucent(Class windowClass) throws Exception {
+        super(windowClass, 1.0f, 0.5f, false);
+    }
+
+    public void doTest() throws Exception {
+        robot.waitForIdle(delay);
+        checkTranslucent();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/PerPixelTranslucentCanvas.java	Tue Aug 26 15:04:49 2014 +0400
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2010, 2014, 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.
+ */
+
+import java.awt.*;
+import javax.swing.*;
+import java.awt.image.BufferedImage;
+
+/*
+ * @test
+ * @summary Check if a per-pixel translucent window shows up with correct translucency
+ * @author mrkam
+ * @library ../../../../lib/testlibrary
+ * @build Common ExtendedRobot
+ * @run main PerPixelTranslucentCanvas
+ */
+
+public class PerPixelTranslucentCanvas extends Common {
+
+    JPanel center;
+    Color OVAL_COLOR = Color.BLUE;
+
+    public static void main(String[] ignored) throws Exception {
+        FG_COLOR = new Color(200, 0, 0, 100);
+        BG_COLOR = Color.GREEN;
+        for (Class<Window> windowClass: WINDOWS_TO_TEST)
+            new PerPixelTranslucentCanvas(windowClass).doTest();
+    }
+
+    public PerPixelTranslucentCanvas(Class windowClass) throws Exception {
+        super(windowClass);
+    }
+
+    @Override
+    public void createSwingComponents() {
+        Container contentPane = RootPaneContainer.class.cast(window).getContentPane();
+        BorderLayout bl = new BorderLayout(10, 10);
+        contentPane.setLayout(bl);
+
+        JLabel label = new JLabel("North", new ImageIcon(
+                new BufferedImage(30, 30, BufferedImage.TYPE_INT_RGB)), SwingConstants.CENTER);
+        contentPane.add(label, BorderLayout.NORTH);
+
+        JButton button = new JButton("West");
+        contentPane.add(button, BorderLayout.WEST);
+
+        center = new JPanel() {
+            @Override
+            public void paint(Graphics g) {
+                g.setColor(OVAL_COLOR);
+                g.fillOval(0, 0, getWidth(), getHeight());
+            }
+        };
+        contentPane.add(center, BorderLayout.CENTER);
+
+        JTextField jTextField = new JTextField("South");
+        contentPane.add(jTextField, BorderLayout.SOUTH);
+    }
+
+    @Override
+    public void doTest() throws Exception {
+        robot.waitForIdle(delay);
+
+        Rectangle bounds = center.getBounds();
+        Point loc = center.getLocationOnScreen();
+
+        final int x = loc.x + bounds.width / 2;
+        final int y = loc.y + bounds.height / 2;
+
+        Color color = robot.getPixelColor(x, y);
+        if (OVAL_COLOR.getRGB() != color.getRGB())
+            throw new RuntimeException("bounds = " + bounds + "\n" +
+                    "loc = " + loc + "\n" +
+                    "background loc = " + background.getX() + ", " + background.getY() + "\n" +
+                    "so middle point over background is " + (x - background.getX()) + ", " + (y - background.getY()) + "\n" +
+                    "Oval is not opaque in the middle point (" + x + ", " + y + ", " + color + ")");
+
+        color = robot.getPixelColor(loc.x - 5, loc.y - 5);
+        if (FG_COLOR.getRGB() == color.getRGB())
+            throw new RuntimeException("Background is not translucent (" + color + ")");
+
+        EventQueue.invokeAndWait(this::dispose);
+        robot.waitForIdle();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/PerPixelTranslucentGradient.java	Tue Aug 26 15:04:49 2014 +0400
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2010, 2014, 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.
+ */
+
+import java.awt.*;
+
+/*
+ * @test
+ * @bug 8032644
+ * @summary Check if a per-pixel translucent window is dragged and resized by
+ *          mouse correctly
+ * Test Description: Check if PERPIXEL_TRANSLUCENT translucency type is supported
+ *      on the current platform. Proceed if they are supported. Create a window
+ *      with some components in it, make window undecorated, apply translucent
+ *      background of 0 and have a gradient painted as background from
+ *      fully-transparent to fully-opaque in componentResized listener. Drag and
+ *      resize the window using AWT Robot and verify that translucency is
+ *      correctly applied with pixels checking. Make the window appear on top of
+ *      a known background. Repeat this for JWindow, JDialog, JFrame.
+ * Expected Result: If PERPIXEL_TRANSLUCENT translucency type is supported,
+ *      the window should appear as specified with the translucency. Only window
+ *      background should be translucent, all the controls should be opaque.
+ * @author mrkam
+ * @library ../../../../lib/testlibrary
+ * @build Common ExtendedRobot
+ * @run main PerPixelTranslucentGradient
+ */
+
+public class PerPixelTranslucentGradient extends Common {
+
+    public static void main(String[] ignored) throws Exception {
+        if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSLUCENT))
+            for (Class<Window> windowClass: WINDOWS_TO_TEST)
+                new PerPixelTranslucentGradient(windowClass).doTest();
+    }
+
+    public PerPixelTranslucentGradient(Class windowClass) throws Exception {
+        super(windowClass, 1.0f, 0f, true);
+    }
+
+    public void doTest() throws Exception {
+        robot.waitForIdle(delay);
+        checkTranslucent();
+    }
+
+    @Override
+    public void applyShape() {
+        gradientWidth = window.getWidth();
+        gradientHeight = window.getHeight();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/PerPixelTranslucentSwing.java	Tue Aug 26 15:04:49 2014 +0400
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2010, 2014, 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.
+ */
+
+import javax.swing.*;
+import java.awt.*;
+
+/*
+ * @test
+ * @summary Check if a per-pixel translucent window shows only the area having
+ *          opaque pixels
+ * Test Description: Check if PERPIXEL_TRANSLUCENT Translucency type is supported
+ *      on the current platform. Proceed if it is supported. Create a swing window
+ *      with some swing components in it and a transparent background (alpha 0.0).
+ *      Bring this window on top of a known background. Do this test for JFrame,
+ *      JWindow and JDialog
+ * Expected Result: Only the components present in the window must be shown. Other
+ *      areas of the window must be transparent so that the background shows
+ * @author mrkam
+ * @library ../../../../lib/testlibrary
+ * @build Common ExtendedRobot
+ * @run main PerPixelTranslucentSwing
+ */
+
+public class PerPixelTranslucentSwing extends Common {
+
+    JButton north;
+
+    public static void main(String[] ignored) throws Exception {
+        FG_COLOR = new Color(200, 0, 0, 0);
+        if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSLUCENT))
+            for (Class<Window> windowClass: WINDOWS_TO_TEST)
+                new PerPixelTranslucentSwing(windowClass).doTest();
+    }
+
+    public PerPixelTranslucentSwing(Class windowClass) throws Exception {
+        super(windowClass);
+    }
+
+    @Override
+    public void createSwingComponents() {
+        Container contentPane = RootPaneContainer.class.cast(window).getContentPane();
+        BorderLayout bl = new BorderLayout(10, 5);
+        contentPane.setLayout(bl);
+
+        north = new JButton("North");
+        contentPane.add(north, BorderLayout.NORTH);
+
+        JList center = new JList(new String[] {"Center"});
+        contentPane.add(center, BorderLayout.CENTER);
+
+        JTextField south = new JTextField("South");
+        contentPane.add(south, BorderLayout.SOUTH);
+
+        window.pack();
+        window.setVisible(true);
+
+        north.requestFocus();
+    }
+
+    @Override
+    public void doTest() throws Exception {
+        robot.waitForIdle(delay);
+
+        // Check for background translucency
+        Rectangle bounds = north.getBounds();
+        Point loc = north.getLocationOnScreen();
+
+        Color color = robot.getPixelColor(loc.x + bounds.width / 2, loc.y + bounds.height + 3);
+        System.out.println(color);
+        if (FG_COLOR.getRGB() == color.getRGB())
+            throw new RuntimeException("Background is not translucent (" + color + ")");
+
+        EventQueue.invokeAndWait(this::dispose);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/SetShapeAndClickSwing.java	Tue Aug 26 15:04:49 2014 +0400
@@ -0,0 +1,172 @@
+/*
+ * Copyright (c) 2010, 2014, 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.
+ */
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.geom.Area;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Rectangle2D;
+
+/*
+ * @test
+ * @summary Check if a window set with shape clips the contents
+ * Test Description: Check if PERPIXEL_TRANSPARENT translucency type is supported
+ *      by the current platform. Proceed if it is supported. Apply different types
+ *      of shapes on a Window which contains some awt components. Shape should be
+ *      applied in such a way that some components are partially clipped off. Check
+ *      if the components appear only partially and events work correctly for those
+ *      components - i.e. events occur only on the areas which appear and do not
+ *      occur on the clipped off areas. Events should be checked by clicking on the
+ *      visible and clipped regions. Repeat this for Window, Dialog and Frame.
+ * Expected Result: If PERPIXEL_TRANSPARENT translucency type is supported, clicking
+ *      on clipped region should deliver the event to the background (it should be
+ *      another Window behind the test window)
+ * @author mrkam
+ * @library ../../../../lib/testlibrary
+ * @build Common ExtendedRobot
+ * @run main SetShapeAndClickSwing
+ */
+
+public class SetShapeAndClickSwing extends Common {
+
+    Component south, center, north;
+
+    public static void main(String[] args) throws Exception {
+        if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
+            for (Class<Window> windowClass: WINDOWS_TO_TEST)
+                new SetShapeAndClickSwing(windowClass).doTest();
+    }
+
+    public SetShapeAndClickSwing(Class windowClass) throws Exception {
+        super(windowClass);
+    }
+
+    @Override
+    public void initBackgroundFrame() {
+        super.initBackgroundFrame();
+        background.addMouseListener(new MouseAdapter() {
+            @Override
+            public void mouseClicked(MouseEvent e) {
+                clicked |= 1 << 0;
+            }
+        });
+    }
+
+    @Override
+    public void createSwingComponents() {
+        window.setSize(200,200);
+        window.setLayout(new BorderLayout());
+
+        south = new JLabel("South");
+        south.addMouseListener(new MouseAdapter() {
+            @Override
+            public void mouseClicked(MouseEvent e) {
+                clicked |= 1 << 3;
+            }
+        });
+        window.add(south, BorderLayout.SOUTH);
+
+        center = new JList();
+        center.addMouseListener(new MouseAdapter() {
+            @Override
+            public void mouseClicked(MouseEvent e) {
+                clicked |= 1 << 2;
+            }
+        });
+        window.add(center, BorderLayout.CENTER);
+
+        north = new JTextField("North");
+        north.addMouseListener(new MouseAdapter() {
+            @Override
+            public void mouseClicked(MouseEvent e) {
+                clicked |= 1 << 1;
+            }
+        });
+        window.add(north, BorderLayout.NORTH);
+    }
+
+    @Override
+    public void doTest() throws Exception {
+
+        robot.waitForIdle();
+
+        Point wls = window.getLocationOnScreen();
+        Point ls;
+        int y;
+        ls = north.getLocationOnScreen();
+        checkClick(ls.x + north.getWidth() / 3, ls.y + north.getHeight() / 2, 1);
+
+        ls = center.getLocationOnScreen();
+        checkClick(ls.x + center.getWidth() * 3 / 4, ls.y + center.getHeight() * 3 / 4, 2);
+
+        ls = south.getLocationOnScreen();
+        checkClick(ls.x + south.getWidth() * 2 / 3, ls.y + south.getHeight() / 2, 3);
+
+        ls = center.getLocationOnScreen();
+        checkClick(ls.x + center.getWidth() / 4, ls.y + center.getHeight() / 4, 2);
+
+        ls = north.getLocationOnScreen();
+        y = ls.y + north.getHeight() / 2;
+        checkClick(wls.x + 200 - (y - wls.y), y, 0);
+
+        EventQueue.invokeAndWait(window::toFront);
+        robot.waitForIdle();
+
+        ls = center.getLocationOnScreen();
+        y = ls.y + center.getHeight() / 2;
+        checkClick(wls.x + 200 - (y - wls.y), y, 0);
+
+        EventQueue.invokeAndWait(window::toFront);
+        robot.waitForIdle();
+
+        ls = south.getLocationOnScreen();
+        y = ls.y + south.getHeight() / 2;
+        checkClick(wls.x + 200 - (y - wls.y), y, 0);
+
+        EventQueue.invokeAndWait(window::dispose);
+        EventQueue.invokeAndWait(background::dispose);
+
+        robot.waitForIdle();
+    }
+
+    @Override
+    public void applyShape() {
+        Area shape = new Area(new Rectangle2D.Float(0, 0, 200, 200));
+        GeneralPath gp;
+        gp = new GeneralPath();
+        gp.moveTo(190, 0);
+        gp.lineTo(200, 0);
+        gp.lineTo(200, 10);
+        gp.lineTo(10, 200);
+        gp.lineTo(0, 200);
+        gp.lineTo(0, 190);
+        gp.closePath();
+        shape.subtract(new Area(gp));
+
+        window.setShape(shape);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/ShapedPerPixelTranslucentGradient.java	Tue Aug 26 15:04:49 2014 +0400
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2010, 2014, 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.
+ */
+
+import java.awt.*;
+
+/*
+ * @test
+ * @bug 7043845
+ * @summary Check if shaped and per-pixel translucent window is dragged and
+ *          resized by mouse correctly.
+ * Test Description: Check if PERPIXEL_TRANSLUCENT and PERPIXEL_TRANSPARENT
+ *      translucency types are supported on the current platform. Proceed if
+ *      they are supported. Create a window with some components in it, make
+ *      window undecorated, apply shape in componentResized listener. The shape
+ *      should match the window size; apply translucent background of 0 and have
+ *      a gradient painted as background from fully-transparent to fully-opaque
+ *      in componentResized listener. Drag and resize the window using AWT Robot
+ *      and verify that shape and translucency are correctly applied with pixels
+ *      checking. Make the window appear on top of a known background. Repeat
+ *      this for JWindow, JDialog, JFrame.
+ * Expected Result: If PERPIXEL_TRANSLUCENT and PERPIXEL_TRANSPARENT translucency
+ *      types are supported, the window should appear as specified with the
+ *      expected shape and translucency. Window background should have
+ *      translucent gradient in parts that are not clipped by shape, all the
+ *      controls should be opaque.
+ * @author mrkam
+ * @library ../../../../lib/testlibrary
+ * @build Common ExtendedRobot
+ * @run main ShapedPerPixelTranslucentGradient
+ */
+
+public class ShapedPerPixelTranslucentGradient extends Common {
+
+    public static void main(String[] ignored) throws Exception {
+        if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSLUCENT)
+            && checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
+            for (Class<Window> windowClass: WINDOWS_TO_TEST)
+                new ShapedPerPixelTranslucentGradient(windowClass).doTest();
+    }
+
+    public ShapedPerPixelTranslucentGradient(Class windowClass) throws Exception {
+        super(windowClass, 1.0f, 0f, true);
+    }
+
+    public void doTest() throws Exception {
+        robot.waitForIdle(delay);
+        checkDynamic();
+    }
+
+    @Override
+    public void applyShape() {
+        applyDynamicShape();
+        gradientWidth = window.getWidth();
+        gradientHeight = window.getHeight();
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/ShapedTranslucentPerPixelTranslucentGradient.java	Tue Aug 26 15:04:49 2014 +0400
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2010, 2014, 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.
+ */
+
+import java.awt.*;
+
+/*
+ * @test
+ * @summary Check if shaped, translucent and per-pixel translucent window is
+ *          dragged and resized by mouse correctly.
+ * Test Description: Check if PERPIXEL_TRANSLUCENT, TRANSLUCENT and
+ *      PERPIXEL_TRANSPARENT translucency types are supported on the current
+ *      platform. Proceed if they are supported. Create a window with some
+ *      components in it, make window undecorated, apply shape in componentResized
+ *      listener. The shape should match the window size; apply opacity of 0.7,
+ *      apply translucent background of 0 and have a gradient painted as
+ *      background from fully-transparent to fully-opaque in componentResized
+ *      listener. Drag and resize the window using AWT Robot and verify that
+ *      shape and translucency are correctly applied with pixels checking. Make
+ *      the window appear on top of a known background. Repeat this for JWindow,
+ *      JDialog, JFrame.
+ * Expected Result: If PERPIXEL_TRANSLUCENT, TRANSLUCENT and PERPIXEL_TRANSPARENT
+ *      translucency types are supported, the window should appear as specified
+ *      with the expected shape and translucency. Window background should have
+ *      translucent gradient in parts that are not clipped by shape, all the
+ *      controls should be equally translucent.
+ * @author mrkam
+ * @library ../../../../lib/testlibrary
+ * @build Common ExtendedRobot
+ * @run main ShapedTranslucentPerPixelTranslucentGradient
+ */
+
+public class ShapedTranslucentPerPixelTranslucentGradient extends Common {
+
+    public static void main(String[] ignored) throws Exception {
+        if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSLUCENT)
+            && checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT)
+            && checkTranslucencyMode(GraphicsDevice.WindowTranslucency.TRANSLUCENT))
+            for (Class<Window> windowClass: WINDOWS_TO_TEST)
+                new ShapedTranslucentPerPixelTranslucentGradient(windowClass).doTest();
+    }
+
+    public ShapedTranslucentPerPixelTranslucentGradient(Class windowClass) throws Exception {
+        super(windowClass, 0.7f, 0f, true);
+    }
+
+    public void doTest() throws Exception {
+        robot.waitForIdle(delay);
+        checkDynamic();
+    }
+
+    @Override
+    public void applyShape() {
+        applyDynamicShape();
+        gradientWidth = window.getWidth();
+        gradientHeight = window.getHeight();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentJComboBox.java	Tue Aug 26 15:04:49 2014 +0400
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2010, 2014, 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.
+ */
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+
+/*
+ * @test
+ * @bug 8024627
+ * @summary Check if a JComboBox present in a window set with opacity less than
+ *          1.0 shows a translucent drop down
+ * Test Description: Check if TRANSLUCENT translucency type is supported on the
+ *      current platform. Proceed if supported. Show a window which contains an
+ *      JComboBox and set with opacity less than 1.0. Another Window having a canvas
+ *      component drawn with an image can be used as the background for the test
+ *      window. Click on the ComboBox to show the drop down. Check if the drop down
+ *      appears translucent. Repeat this for JWindow, JDialog and JFrame
+ * Expected Result: If TRANSLUCENT Translucency type is supported, the drop down
+ *      should appear translucent.
+ * @author mrkam
+ * @library ../../../../lib/testlibrary
+ * @build Common ExtendedRobot
+ * @run main TranslucentJComboBox
+ */
+
+public class TranslucentJComboBox extends Common {
+
+    JComponent south;
+    JComponent center;
+    JPanel north;
+    volatile boolean southClicked = false;
+
+    public static void main(String[] args) throws Exception {
+        if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.TRANSLUCENT))
+            for (Class<Window> windowClass: WINDOWS_TO_TEST)
+                new TranslucentJComboBox(windowClass).doTest();
+    }
+
+    public TranslucentJComboBox(Class windowClass) throws Exception {
+        super(windowClass, 0.3f, 1.0f, false);
+    }
+
+    @Override
+    public void initBackgroundFrame() {
+        super.initBackgroundFrame();
+    }
+
+    @Override
+    public void createSwingComponents() {
+        Container contentPane = RootPaneContainer.class.cast(window).getContentPane();
+        window.setLayout(new BorderLayout());
+
+        north = new JPanel();
+        contentPane.add(north, BorderLayout.NORTH);
+
+        center = new JList(new String [] { "Center" });
+        contentPane.add(center, BorderLayout.CENTER);
+
+        JComboBox jComboBox = new JComboBox();
+        for(int i = 0; i < 20; i++) {
+            jComboBox.addItem("item " + i);
+        }
+        south = jComboBox;
+
+        south.addMouseListener(new MouseAdapter() {
+            @Override
+            public void mouseClicked(MouseEvent e) {
+                southClicked = true;
+            }
+        });
+        contentPane.add(south, BorderLayout.SOUTH);
+    }
+
+
+    @Override
+    public void doTest() throws Exception {
+        robot.waitForIdle(delay);
+        // Make window an active
+        Point ls = north.getLocationOnScreen();
+        robot.mouseMove(ls.x + north.getWidth()/2, ls.y + north.getHeight()/2);
+        robot.click();
+
+        // Invoke list
+        ls = south.getLocationOnScreen();
+
+        Point p1 = new Point(
+                (int) (ls.x + south.getWidth() * 0.75),
+                ls.y + south.getHeight() * 3);
+
+        Point p2 = new Point(
+                (int) (ls.x + south.getWidth() * 0.75),
+                ls.y - south.getHeight() * 2);
+
+        Color c1 = robot.getPixelColor(p1.x, p1.y);
+        Color c2 = robot.getPixelColor(p2.x, p2.y);
+
+        int x = ls.x + south.getWidth()/2;
+        int y = ls.y + south.getHeight()/2;
+
+        System.out.println("Trying to click point "+x+", "+y+
+                ", looking for flag to trigger.");
+
+        robot.mouseMove(x, y);
+        robot.waitForIdle(delay);
+        robot.click();
+        robot.waitForIdle(delay);
+
+        if (!southClicked)
+            throw new RuntimeException("Flag is not triggered for point "+x+", "+y+"!");
+
+        robot.waitForIdle();
+
+        Color c1b = robot.getPixelColor(p1.x, p1.y);
+        Color c2b = robot.getPixelColor(p2.x, p2.y);
+
+        if (!c1.equals(c1b) && !south.getBackground().equals(c1b))
+            throw new RuntimeException(
+                    "Check for opaque drop down failed at point " + p1 +
+                            ". Before click: " + c1 + ", after click: " + c1b +
+                            ", expected is " + south.getBackground());
+
+        if (!c2.equals(c2b) && !south.getBackground().equals(c2b))
+            throw new RuntimeException(
+                    "Check for opaque drop down failed at point " + p2 +
+                            ". Before click: " + c2 + ", after click: " + c2b +
+                            ", expected is " + south.getBackground());
+
+        EventQueue.invokeAndWait(this::dispose);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentPerPixelTranslucentGradient.java	Tue Aug 26 15:04:49 2014 +0400
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2010, 2014, 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.
+ */
+
+import java.awt.*;
+
+/*
+ * @test
+ * @summary Check if a per-pixel translucent and translucent window is dragged
+ *          and resized by mouse correctly
+ * Test Description: Check if PERPIXEL_TRANSLUCENT and TRANSLUCENT translucency
+ *      types are supported on the current platform. Proceed if they are supported.
+ *      Create a window with some components in it, make window undecorated, apply
+ *      opacity of 0.7, apply translucent background of 0 and have a gradient
+ *      painted as background from fully-transparent to fully-opaque in
+ *      componentResized listener. Drag and resize the window using AWT Robot and
+ *      verify that translucency is correctly applied with pixels checking. Make
+ *      the window appear on top of a known background. Repeat this for specified
+ *      JWindow, JDialog, JFrame.
+ * Expected Result: If PERPIXEL_TRANSLUCENT and TRANSLUCENT translucency types
+ *      are supported, the window should appear as specified with the translucency.
+ *      Both window background and all the controls should be translucent but
+ *      background should have a gradient in translucency while controls - not.
+ * @author mrkam
+ * @library ../../../../lib/testlibrary
+ * @build Common ExtendedRobot
+ * @run main TranslucentPerPixelTranslucentGradient
+ */
+
+public class TranslucentPerPixelTranslucentGradient extends Common {
+
+    public static void main(String[] ignored) throws Exception {
+        if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSLUCENT)
+            && checkTranslucencyMode(GraphicsDevice.WindowTranslucency.TRANSLUCENT))
+            for (Class<Window> windowClass: WINDOWS_TO_TEST)
+                new TranslucentPerPixelTranslucentGradient(windowClass).doTest();
+    }
+
+    public TranslucentPerPixelTranslucentGradient(Class windowClass) throws Exception {
+        super(windowClass, 0.7f, 0f, true);
+    }
+
+    public void doTest() throws Exception {
+        robot.waitForIdle(delay);
+        checkTranslucent();
+    }
+
+    @Override
+    public void applyShape() {
+        gradientWidth = window.getWidth();
+        gradientHeight = window.getHeight();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentWindowClickSwing.java	Tue Aug 26 15:04:49 2014 +0400
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2010, 2014, 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.
+ */
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+
+/*
+ * @test
+ * @summary Check if swing components present in a window set with opacity less
+ *          than 1.0 appears translucent
+ * Test Description: Check if TRANSLUCENT Translucency type is supported for the
+ *      current platform. Proceed if supported. Show a window containing some swing
+ *      components and set it with opacity less than 1.0. Check if the swing components
+ *      appear translucent and check if events trigger correctly for the components
+ * Expected Result: If TRANSLUCENT Translucency type is supported, the components
+ *      should appear translucent showing the background. They should trigger events
+ *      correctly
+ * @author mrkam
+ * @library ../../../../lib/testlibrary
+ * @build Common ExtendedRobot
+ * @run main TranslucentWindowClickSwing
+ */
+
+public class TranslucentWindowClickSwing extends Common {
+
+    private Component south;
+    private Component center;
+    private Component north;
+
+    public static void main(String[] args) throws Exception{
+        if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.TRANSLUCENT))
+            new TranslucentWindowClickSwing(JWindow.class).doTest();
+    }
+
+    public TranslucentWindowClickSwing(Class windowClass) throws Exception {
+        super(windowClass, 0.2f, 1.0f, false);
+    }
+
+    @Override
+    public void createSwingComponents() {
+        south = new JButton("South");
+        south.addMouseListener(new MouseAdapter() {
+            @Override
+            public void mouseClicked(MouseEvent e) { clicked |= 1 << 2; }
+        });
+        window.add(south, BorderLayout.SOUTH);
+
+        center = new JList();
+        center.addMouseListener(new MouseAdapter() {
+            @Override
+            public void mouseClicked(MouseEvent e) { clicked |= 1 << 1; }
+        });
+        window.add(center, BorderLayout.CENTER);
+
+        north = new JTextField("North");
+        north.addMouseListener(new MouseAdapter() {
+            @Override
+            public void mouseClicked(MouseEvent e) { clicked |= 1 << 0; }
+        });
+        window.add(north, BorderLayout.NORTH);
+    }
+
+    @Override
+    public void doTest() throws Exception {
+        Point ls;
+        robot.waitForIdle();
+
+        ls = north.getLocationOnScreen();
+        checkClick(ls.x + north.getWidth() / 3, ls.y + north.getHeight() / 2, 0);
+
+        ls = center.getLocationOnScreen();
+        checkClick(ls.x + center.getWidth() / 4, ls.y + center.getHeight() / 4, 1);
+
+        ls = center.getLocationOnScreen();
+        checkClick(ls.x + center.getWidth() * 3 / 4, ls.y + center.getHeight() * 3 / 4, 1);
+
+        ls = south.getLocationOnScreen();
+        checkClick(ls.x + south.getWidth() * 2 / 3, ls.y + south.getHeight() / 2, 2);
+
+        EventQueue.invokeAndWait(this::dispose);
+        robot.waitForIdle();
+    }
+}