8209494: Create a test for SwingSet InternalFrameDemo
authorakolarkunnu
Mon, 27 Aug 2018 03:48:41 -0700
changeset 51538 da387726a4f5
parent 51537 a5d47d1b2a74
child 51539 2af74a1edb11
8209494: Create a test for SwingSet InternalFrameDemo Reviewed-by: serb Contributed-by: abdul.kolarkunnu@oracle.com
test/jdk/sanity/client/SwingSet/src/InternalFrameDemoTest.java
test/jdk/sanity/client/lib/SwingSet3/src/com/sun/swingset3/demos/internalframe/InternalFrameDemo.java
test/jdk/sanity/client/lib/SwingSet3/src/com/sun/swingset3/demos/internalframe/resources/InternalFrameDemo.properties
test/jdk/sanity/client/lib/SwingSet3/src/com/sun/swingset3/demos/internalframe/resources/images/InternalFrameDemo.gif
test/jdk/sanity/client/lib/SwingSet3/src/com/sun/swingset3/demos/internalframe/resources/images/bananas.png
test/jdk/sanity/client/lib/SwingSet3/src/com/sun/swingset3/demos/internalframe/resources/images/bananas_small.png
test/jdk/sanity/client/lib/SwingSet3/src/com/sun/swingset3/demos/internalframe/resources/images/globe.png
test/jdk/sanity/client/lib/SwingSet3/src/com/sun/swingset3/demos/internalframe/resources/images/globe_small.png
test/jdk/sanity/client/lib/SwingSet3/src/com/sun/swingset3/demos/internalframe/resources/images/package.png
test/jdk/sanity/client/lib/SwingSet3/src/com/sun/swingset3/demos/internalframe/resources/images/package_small.png
test/jdk/sanity/client/lib/SwingSet3/src/com/sun/swingset3/demos/internalframe/resources/images/soccer_ball.png
test/jdk/sanity/client/lib/SwingSet3/src/com/sun/swingset3/demos/internalframe/resources/images/soccer_ball_small.png
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sanity/client/SwingSet/src/InternalFrameDemoTest.java	Mon Aug 27 03:48:41 2018 -0700
@@ -0,0 +1,352 @@
+/*
+ * Copyright (c) 2018, 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 static com.sun.swingset3.demos.internalframe.InternalFrameDemo.CLOSABLE_LABEL;
+import static com.sun.swingset3.demos.internalframe.InternalFrameDemo.DEMO_TITLE;
+import static com.sun.swingset3.demos.internalframe.InternalFrameDemo.FRAME0_X;
+import static com.sun.swingset3.demos.internalframe.InternalFrameDemo.FRAME0_Y;
+import static com.sun.swingset3.demos.internalframe.InternalFrameDemo.FRAME_GAP;
+import static com.sun.swingset3.demos.internalframe.InternalFrameDemo.FRAME_HEIGHT;
+import static com.sun.swingset3.demos.internalframe.InternalFrameDemo.FRAME_WIDTH;
+import static com.sun.swingset3.demos.internalframe.InternalFrameDemo.ICONIFIABLE_LABEL;
+import static com.sun.swingset3.demos.internalframe.InternalFrameDemo.INTERNAL_FRAME_LABEL;
+import static com.sun.swingset3.demos.internalframe.InternalFrameDemo.MAXIMIZABLE_LABEL;
+import static com.sun.swingset3.demos.internalframe.InternalFrameDemo.PALETTE_HEIGHT;
+import static com.sun.swingset3.demos.internalframe.InternalFrameDemo.PALETTE_LABEL;
+import static com.sun.swingset3.demos.internalframe.InternalFrameDemo.PALETTE_WIDTH;
+import static com.sun.swingset3.demos.internalframe.InternalFrameDemo.PALETTE_X;
+import static com.sun.swingset3.demos.internalframe.InternalFrameDemo.PALETTE_Y;
+import static com.sun.swingset3.demos.internalframe.InternalFrameDemo.RESIZABLE_LABEL;
+import static org.jemmy2ext.JemmyExt.EXACT_STRING_COMPARATOR;
+import static org.testng.AssertJUnit.assertFalse;
+
+import java.awt.Dimension;
+import java.awt.Point;
+
+import javax.swing.JDesktopPane;
+import javax.swing.JInternalFrame;
+
+import org.jemmy2ext.JemmyExt;
+import org.jtregext.GuiTestListener;
+import org.netbeans.jemmy.ClassReference;
+import org.netbeans.jemmy.operators.ComponentOperator;
+import org.netbeans.jemmy.operators.JButtonOperator;
+import org.netbeans.jemmy.operators.JCheckBoxOperator;
+import org.netbeans.jemmy.operators.JFrameOperator;
+import org.netbeans.jemmy.operators.JInternalFrameOperator;
+import org.netbeans.jemmy.operators.JTextFieldOperator;
+import org.testng.annotations.Listeners;
+import org.testng.annotations.Test;
+
+import com.sun.swingset3.demos.internalframe.InternalFrameDemo;
+
+/*
+ * @test
+ * @key headful
+ * @summary Verifies SwingSet3 InternalFrameDemo page by checking the different
+ *  actions on the parent frame, internal frame and creating internal frame
+ *  with different properties
+ *
+ * @library /sanity/client/lib/jemmy/src
+ * @library /sanity/client/lib/Extensions/src
+ * @library /sanity/client/lib/SwingSet3/src
+ * @modules java.desktop
+ *          java.logging
+ * @build org.jemmy2ext.JemmyExt
+ * @build com.sun.swingset3.demos.internalframe.InternalFrameDemo
+ * @run testng InternalFrameDemoTest
+ */
+@Listeners(GuiTestListener.class)
+public class InternalFrameDemoTest {
+
+    private final static int PARENT_FRAME_NEW_SIZE_DELTA = 300;
+    private final static int PARENT_FRAME_NEW_LOCATION_DELTA = 200;
+    private final static Dimension INTERNAL_FRAME_NEW_SIZE = new Dimension(400, 400);
+    private final static Point INTERNAL_FRAME_NEW_LOCATION = new Point(390, 120);
+    private final static int DELAY = 500;
+    private final static String INTERNAL_FRAME_NEW_NAME = "New Internal Frame";
+
+    /**
+     * Testing the different actions on the parent frame, internal frame and
+     * creating internal frame with different properties
+     *
+     * @throws Exception
+     */
+    @Test
+    public void test() throws Exception {
+
+        new ClassReference(InternalFrameDemo.class.getCanonicalName()).startApplication();
+
+        JFrameOperator frameOperator = new JFrameOperator(DEMO_TITLE);
+        frameOperator.setComparator(EXACT_STRING_COMPARATOR);
+        frameOperator.setVerification(true);
+
+        // verifying internal frame primary properties
+        JInternalFrameOperator internalFrameOperator = new JInternalFrameOperator(
+                frameOperator, getInternalFrameName(INTERNAL_FRAME_LABEL, 0));
+        internalFrameOperator.setVerification(true);
+        checkInternalFramePrimaryProps(internalFrameOperator,
+                new Point(FRAME0_X, FRAME0_Y), new Dimension(FRAME_WIDTH, FRAME_HEIGHT));
+
+        // Verifying the internal frame properties after doing different
+        // actions on parent frame
+        checkParentFrameAction(frameOperator, internalFrameOperator);
+
+        // Verifying different actions on the internal frame
+        checkInternalFrameAction(internalFrameOperator);
+
+        // Creating internal frames with different action properties
+        // and verifying their properties
+        checkPaletteFrameAction(frameOperator);
+    }
+
+    /**
+     * Verifying the internal frame properties after doing different actions on
+     * parent frame, it should not affect internal frame.
+     *
+     * @param parentFrameOperator : parent fame operator
+     * @param internalFrameOperator : internal fame operator
+     * @throws InterruptedException
+     */
+    private void checkParentFrameAction(JFrameOperator parentFrameOperator,
+            JInternalFrameOperator internalFrameOperator) throws InterruptedException {
+
+        // Resizing the parent frame and verifying the size of the internal
+        // frame(it should not be resized)
+        Dimension orignalSize = parentFrameOperator.getSize();
+        Dimension newSize = new Dimension(orignalSize.width - PARENT_FRAME_NEW_SIZE_DELTA,
+                orignalSize.height - PARENT_FRAME_NEW_SIZE_DELTA);
+        parentFrameOperator.resize(newSize.width, newSize.height);
+        parentFrameOperator.waitComponentSize(newSize);
+        // keeping some delay before checking the internal frame property
+        // as it is a negative scenario
+        Thread.sleep(DELAY);
+        internalFrameOperator.waitComponentSize(new Dimension(FRAME_WIDTH, FRAME_HEIGHT));
+        // Resizing parent frame back to original size
+        parentFrameOperator.resize(orignalSize.width, orignalSize.height);
+        parentFrameOperator.waitComponentSize(orignalSize);
+
+        // Iconifying the parent frame and verifying the iconified status of the internal
+        // frame(it should not be iconified)
+        parentFrameOperator.iconify();
+        // keeping some delay before checking the internal frame property
+        // as it is a negative scenario
+        Thread.sleep(DELAY);
+        assertFalse("Internal Frame should not be iconified when parent frame"
+                + " alone is iconified.", internalFrameOperator.isIcon());
+        parentFrameOperator.deiconify();
+
+        // Maximizing the parent frame and verifying the maximized status of the internal
+        // frame(it should not be maximized)
+        parentFrameOperator.maximize();
+        // keeping some delay before checking the internal frame property
+        // as it is a negative scenario
+        Thread.sleep(DELAY);
+        assertFalse("Internal Frame should not be maximized when parent frame"
+                + " alone is maximized.", internalFrameOperator.isMaximum());
+        parentFrameOperator.demaximize();
+
+        // Relocating the parent frame and verifying the location of the internal
+        // frame(it should not be changed the location)
+        Point orignalLocation = parentFrameOperator.getLocation();
+        Point newLocation = new Point((orignalLocation.x - PARENT_FRAME_NEW_LOCATION_DELTA),
+                (orignalLocation.y + PARENT_FRAME_NEW_LOCATION_DELTA));
+        parentFrameOperator.move(newLocation.x, newLocation.y);
+        parentFrameOperator.waitComponentLocation(newLocation);
+        // keeping some delay before checking the internal frame property
+        // as it is a negative scenario
+        Thread.sleep(DELAY);
+        internalFrameOperator.waitComponentLocation(new Point(FRAME0_X, FRAME0_Y));
+        // Moving back parent frame to original location
+        parentFrameOperator.move(orignalLocation.x, orignalLocation.y);
+        parentFrameOperator.waitComponentLocation(orignalLocation);
+    }
+
+    /**
+     * Verifying different actions on the internal frame.
+     *
+     * @param internalFrameOperator : internal fame operator
+     */
+    private void checkInternalFrameAction(
+            JInternalFrameOperator internalFrameOperator) {
+        // Verifying maximize and demaximize actions
+        internalFrameOperator.waitStateOnQueue(comp
+                -> ((JInternalFrame)comp).isMaximizable());
+        internalFrameOperator.maximize();
+        internalFrameOperator.demaximize();
+
+        // Verifying iconify and deiconify actions
+        internalFrameOperator.waitStateOnQueue(comp
+                -> ((JInternalFrame)comp).isIconifiable());
+        internalFrameOperator.iconify();
+        internalFrameOperator.deiconify();
+
+        // Verifying resize action
+        internalFrameOperator.waitStateOnQueue(comp
+                -> ((JInternalFrame)comp).isResizable());
+        TestHelpers.checkChangeSize(internalFrameOperator,
+                INTERNAL_FRAME_NEW_SIZE);
+
+        // Verifying move action
+        TestHelpers.checkChangeLocation(internalFrameOperator,
+                INTERNAL_FRAME_NEW_LOCATION);
+
+        // Verifying close action
+        internalFrameOperator.waitStateOnQueue(comp
+                -> ((JInternalFrame)comp).isClosable());
+        internalFrameOperator.close();
+    }
+
+    /**
+     * Creating internal frames with different action properties and verifying
+     * their properties
+     *
+     * @param frameOperator : parent frame operator
+     */
+    private void checkPaletteFrameAction(JFrameOperator frameOperator) {
+        // Getting palette frame and checking the properties of it
+        JInternalFrameOperator paletteFrameOperator =
+                new JInternalFrameOperator(frameOperator, PALETTE_LABEL);
+        paletteFrameOperator.setComparator(EXACT_STRING_COMPARATOR);
+        checkInternalFramePrimaryProps(paletteFrameOperator,
+                new Point(PALETTE_X, PALETTE_Y),
+                new Dimension(PALETTE_WIDTH, PALETTE_HEIGHT));
+
+        // Getting all check boxes to set/reset frame properties
+        JCheckBoxOperator closableOperator =
+                new JCheckBoxOperator(paletteFrameOperator, CLOSABLE_LABEL);
+        JCheckBoxOperator iconifiableOperator =
+                new JCheckBoxOperator(paletteFrameOperator, ICONIFIABLE_LABEL);
+        JCheckBoxOperator maximizableOperator =
+                new JCheckBoxOperator(paletteFrameOperator, MAXIMIZABLE_LABEL);
+        JCheckBoxOperator resizableOperator =
+                new JCheckBoxOperator(paletteFrameOperator, RESIZABLE_LABEL);
+        JCheckBoxOperator[] checkBoxes = {closableOperator, iconifiableOperator,
+                maximizableOperator, resizableOperator};
+
+        // Verifying internal frame with all action properties set to false
+        checkFrameProps(frameOperator, paletteFrameOperator,
+                getInternalFrameName(INTERNAL_FRAME_LABEL, 1), 1, checkBoxes, false);
+
+        // Verifying internal frame with all action properties set to true and setting title
+        JTextFieldOperator frameTitle = new JTextFieldOperator(paletteFrameOperator);
+        frameTitle.setText(INTERNAL_FRAME_NEW_NAME);
+        checkFrameProps(frameOperator, paletteFrameOperator,
+                getInternalFrameName(INTERNAL_FRAME_NEW_NAME), 2, checkBoxes, true);
+    }
+
+    /**
+     * Verifying internal frame properties
+     *
+     * @param frameOperator : parent frame operator
+     * @param paletteFrameOperator : palette frame operator
+     * @param title : title of the internal frame
+     * @param index : index of the internal frame
+     * @param checkBoxes : array of check boxes
+     * @param checkBoxStatus : status of check box
+     */
+    private void checkFrameProps(JFrameOperator frameOperator,
+            JInternalFrameOperator paletteFrameOperator,
+            String title, int index, JCheckBoxOperator[] checkBoxes,
+            boolean checkBoxStatus) {
+
+        pushCheckBoxes(checkBoxes, checkBoxStatus);
+        JButtonOperator button = new JButtonOperator(paletteFrameOperator, (index -1));
+        button.push();
+        JInternalFrameOperator internalFrameOperator =
+                new JInternalFrameOperator(frameOperator, title);
+        int gap = FRAME_GAP * index;
+        checkInternalFramePrimaryProps(internalFrameOperator,
+                new Point(FRAME0_X + gap, FRAME0_Y + gap),
+                new Dimension(FRAME_WIDTH, FRAME_HEIGHT));
+        checkFrameActionProps(internalFrameOperator, checkBoxStatus);
+        ComponentOperator desktopOperator = new ComponentOperator(
+                frameOperator, new JemmyExt.ByClassChooser(JDesktopPane.class));
+        frameOperator.waitStateOnQueue(comp -> ((JDesktopPane)desktopOperator.
+                getSource()).getAllFrames().length == index + 1);
+    }
+
+    /**
+     * Verifying internal frame primary properties like showing status, location and size
+     * @param internalFrameOperator
+     * @param location
+     * @param size
+     */
+    private void checkInternalFramePrimaryProps(JInternalFrameOperator internalFrameOperator,
+            Point location, Dimension size) {
+        internalFrameOperator.waitComponentShowing(true);
+        internalFrameOperator.waitComponentLocation(location);
+        internalFrameOperator.waitComponentSize(size);
+    }
+
+    /**
+     * Verifying internal frame action status
+     *
+     * @param internalFrameOperator : internal frame operator
+     * @param propertyStatus : status to check
+     */
+    private void checkFrameActionProps(JInternalFrameOperator internalFrameOperator,
+            boolean propertyStatus) {
+        internalFrameOperator.waitStateOnQueue(comp
+                -> ((JInternalFrame)comp).isClosable() == propertyStatus);
+        internalFrameOperator.waitStateOnQueue(comp
+                -> ((JInternalFrame)comp).isIconifiable() == propertyStatus);
+        internalFrameOperator.waitStateOnQueue(comp
+                -> ((JInternalFrame)comp).isMaximizable() == propertyStatus);
+        internalFrameOperator.waitStateOnQueue(comp
+                -> ((JInternalFrame)comp).isResizable() == propertyStatus);
+    }
+
+    /**
+     * To set/reset check boxes
+     *
+     * @param checkBoxes : array of check boxes
+     * @param select : set/reset
+     */
+    private void pushCheckBoxes(JCheckBoxOperator []checkBoxes, boolean select){
+        for (JCheckBoxOperator checkBox : checkBoxes) {
+            checkBox.push();
+            checkBox.waitSelected(select);
+        }
+    }
+
+    /**
+     * Gets the internal frame name
+     * @param frameLabel
+     * @return
+     */
+    private String getInternalFrameName(String frameLabel) {
+        return (frameLabel+ "  ");
+    }
+
+    /**
+     * Gets the internal frame name
+     * @param frameLabel
+     * @param index
+     * @return
+     */
+    private String getInternalFrameName(String frameLabel, int index) {
+        return getInternalFrameName(frameLabel+ " " + index);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sanity/client/lib/SwingSet3/src/com/sun/swingset3/demos/internalframe/InternalFrameDemo.java	Mon Aug 27 03:48:41 2018 -0700
@@ -0,0 +1,378 @@
+/*
+ * Copyright (c) 2018, 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.
+ */
+
+package com.sun.swingset3.demos.internalframe;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JDesktopPane;
+import javax.swing.JFrame;
+import javax.swing.JInternalFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+import javax.swing.border.EmptyBorder;
+
+import com.sun.swingset3.DemoProperties;
+import com.sun.swingset3.demos.ResourceManager;
+
+
+/**
+ * Internal Frames Demo
+ *
+ * @version 1.16 11/17/05
+ * @author Jeff Dinkins
+ */
+@DemoProperties(
+        value = "JInternalFrame Demo",
+        category = "Containers",
+        description = "Demonstrates JInternalFrame, a frame which can be embedded within another container to" +
+                "implement an MDI style interface.",
+        sourceFiles = {
+                "com/sun/swingset3/demos/internalframe/InternalFrameDemo.java",
+                "com/sun/swingset3/demos/ResourceManager.java",
+                "com/sun/swingset3/demos/internalframe/resources/InternalFrameDemo.properties",
+                "com/sun/swingset3/demos/internalframe/resources/images/bananas.png",
+                "com/sun/swingset3/demos/internalframe/resources/images/bananas_small.png",
+                "com/sun/swingset3/demos/internalframe/resources/images/globe.png",
+                "com/sun/swingset3/demos/internalframe/resources/images/globe_small.png",
+                "com/sun/swingset3/demos/internalframe/resources/images/InternalFrameDemo.gif",
+                "com/sun/swingset3/demos/internalframe/resources/images/package.png",
+                "com/sun/swingset3/demos/internalframe/resources/images/package_small.png",
+                "com/sun/swingset3/demos/internalframe/resources/images/soccer_ball.png",
+                "com/sun/swingset3/demos/internalframe/resources/images/soccer_ball_small.png"
+                }
+)
+public class InternalFrameDemo extends JPanel {
+
+    public static final String DEMO_TITLE = InternalFrameDemo.class.getAnnotation(DemoProperties.class).value();
+    public static final String PALETTE_LABEL;
+    public static final String INTERNAL_FRAME_LABEL;
+    public static final String RESIZABLE_LABEL;
+    public static final String ICONIFIABLE_LABEL;
+    public static final String CLOSABLE_LABEL;
+    public static final String MAXIMIZABLE_LABEL;
+
+    public static final int PALETTE_X = 20;
+    public static final int PALETTE_Y = 20;
+
+    public static final int PALETTE_WIDTH = 250;
+    public static final int PALETTE_HEIGHT = 250;
+
+    public static final int FRAME_WIDTH = 300;
+    public static final int FRAME_HEIGHT = 300;
+
+    public static final int FRAME0_X = PALETTE_X + PALETTE_WIDTH + 20;
+    public static final int FRAME0_Y = 20;
+    public static final int FRAME_GAP = 20;
+
+    private static final Dimension HGAP5 = new Dimension(5, 1);
+    private static final Dimension VGAP10 = new Dimension(1, 10);
+    private static final Dimension HGAP15 = new Dimension(15, 1);
+    private static final Dimension VGAP15 = new Dimension(1, 15);
+
+    private final static ResourceManager resourceManager = new ResourceManager(InternalFrameDemo.class);
+
+    static {
+        PALETTE_LABEL = resourceManager.getString("InternalFrameDemo.palette_label");
+        INTERNAL_FRAME_LABEL = resourceManager.getString("InternalFrameDemo.frame_label");
+        RESIZABLE_LABEL = resourceManager.getString("InternalFrameDemo.resizable_label");
+        ICONIFIABLE_LABEL = resourceManager.getString("InternalFrameDemo.iconifiable_label");
+        CLOSABLE_LABEL = resourceManager.getString("InternalFrameDemo.closable_label");
+        MAXIMIZABLE_LABEL = resourceManager.getString("InternalFrameDemo.maximizable_label");
+    }
+
+    private int windowCount = 0;
+    private JDesktopPane desktop = null;
+
+    private final ImageIcon icon1;
+    private final ImageIcon icon2;
+    private final ImageIcon icon3;
+    private final ImageIcon icon4;
+    private final ImageIcon smIcon1;
+    private final ImageIcon smIcon2;
+    private final ImageIcon smIcon3;
+    private final ImageIcon smIcon4;
+
+    private final Integer DEMO_FRAME_LAYER = new Integer(2);
+    private final Integer PALETTE_LAYER = new Integer(3);
+
+    private JCheckBox windowResizable = null;
+    private JCheckBox windowClosable = null;
+    private JCheckBox windowIconifiable = null;
+    private JCheckBox windowMaximizable = null;
+
+    private JTextField windowTitleField = null;
+    private JLabel windowTitleLabel = null;
+
+
+    /**
+     * main method allows us to run as a standalone demo.
+     */
+    public static void main(String[] args) {
+        JFrame frame = new JFrame(DEMO_TITLE);
+
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        frame.getContentPane().add(new InternalFrameDemo());
+        frame.setPreferredSize(new Dimension(800, 600));
+        frame.pack();
+        frame.setLocationRelativeTo(null);
+        frame.setVisible(true);
+    }
+
+    /**
+     * InternalFrameDemo Constructor
+     */
+    public InternalFrameDemo() {
+        setLayout(new BorderLayout());
+
+        // preload all the icons we need for this demo
+        icon1 = resourceManager.createImageIcon("bananas.png",
+                resourceManager.getString("InternalFrameDemo.bananas"));
+        icon2 = resourceManager.createImageIcon("globe.png",
+                resourceManager.getString("InternalFrameDemo.globe"));
+        icon3 = resourceManager.createImageIcon("package.png",
+                resourceManager.getString("InternalFrameDemo.package"));
+        icon4 = resourceManager.createImageIcon("soccer_ball.png",
+                resourceManager.getString("InternalFrameDemo.soccerball"));
+
+        smIcon1 = resourceManager.createImageIcon("bananas_small.png",
+                resourceManager.getString("InternalFrameDemo.bananas"));
+        smIcon2 = resourceManager.createImageIcon("globe_small.png",
+                resourceManager.getString("InternalFrameDemo.globe"));
+        smIcon3 = resourceManager.createImageIcon("package_small.png",
+                resourceManager.getString("InternalFrameDemo.package"));
+        smIcon4 = resourceManager.createImageIcon("soccer_ball_small.png",
+                resourceManager.getString("InternalFrameDemo.soccerball"));
+
+        //<snip>Create desktop pane
+        // The desktop pane will contain all the internal frames
+        desktop = new JDesktopPane();
+        add(desktop, BorderLayout.CENTER);
+        //</snip>
+
+        // Create the "frame maker" palette
+        createInternalFramePalette();
+
+        // Create an initial internal frame to show
+        JInternalFrame frame1 = createInternalFrame(icon2, DEMO_FRAME_LAYER, 1, 1);
+        frame1.setBounds(FRAME0_X, FRAME0_Y, FRAME_WIDTH, FRAME_HEIGHT);
+
+    }
+
+
+    /**
+     * Create an internal frame and add a scrollable imageicon to it
+     */
+    private JInternalFrame createInternalFrame(Icon icon, Integer layer, int width, int height) {
+        //<snip>Create internal frame
+        JInternalFrame internalFrame = new JInternalFrame();
+        //</snip>
+
+        if (!windowTitleField.getText().equals(resourceManager.getString("InternalFrameDemo.frame_label"))) {
+            internalFrame.setTitle(windowTitleField.getText() + "  ");
+        } else {
+            internalFrame = new JInternalFrame(INTERNAL_FRAME_LABEL + " " + windowCount + "  ");
+        }
+
+        //<snip>Set internal frame properties
+        internalFrame.setClosable(windowClosable.isSelected());
+        internalFrame.setMaximizable(windowMaximizable.isSelected());
+        internalFrame.setIconifiable(windowIconifiable.isSelected());
+        internalFrame.setResizable(windowResizable.isSelected());
+        //</snip>
+
+        internalFrame.setBounds(FRAME0_X + FRAME_GAP * (windowCount % 10),
+                FRAME0_Y + FRAME_GAP * (windowCount % 10), width, height);
+        internalFrame.setContentPane(new ImageScroller(icon));
+
+        windowCount++;
+
+        //<snip>Add internal frame to desktop pane
+        desktop.add(internalFrame, layer);
+        //</snip>
+
+        //<snip>Set internal frame to be active
+        try {
+            internalFrame.setSelected(true);
+        } catch (java.beans.PropertyVetoException e2) {
+        }
+        //</snip>
+
+        internalFrame.show();
+
+        return internalFrame;
+    }
+
+    private void createInternalFramePalette() {
+        JInternalFrame palette = new JInternalFrame(PALETTE_LABEL);
+        palette.putClientProperty("JInternalFrame.isPalette", Boolean.TRUE);
+        palette.getContentPane().setLayout(new BorderLayout());
+        palette.setBounds(PALETTE_X, PALETTE_Y, PALETTE_WIDTH, PALETTE_HEIGHT);
+        palette.setResizable(true);
+        palette.setIconifiable(true);
+        desktop.add(palette, PALETTE_LAYER);
+
+        // *************************************
+        // * Create create frame maker buttons *
+        // *************************************
+        JButton b1 = new JButton(smIcon1);
+        JButton b2 = new JButton(smIcon2);
+        JButton b3 = new JButton(smIcon3);
+        JButton b4 = new JButton(smIcon4);
+
+        // add frame maker actions
+        b1.addActionListener(new CreateFrameAction(this, icon1));
+        b2.addActionListener(new CreateFrameAction(this, icon2));
+        b3.addActionListener(new CreateFrameAction(this, icon3));
+        b4.addActionListener(new CreateFrameAction(this, icon4));
+
+        // add frame maker buttons to panel
+        JPanel p = new JPanel();
+        p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
+
+        JPanel buttons1 = new JPanel();
+        buttons1.setLayout(new BoxLayout(buttons1, BoxLayout.X_AXIS));
+
+        JPanel buttons2 = new JPanel();
+        buttons2.setLayout(new BoxLayout(buttons2, BoxLayout.X_AXIS));
+
+        buttons1.add(b1);
+        buttons1.add(Box.createRigidArea(HGAP15));
+        buttons1.add(b2);
+
+        buttons2.add(b3);
+        buttons2.add(Box.createRigidArea(HGAP15));
+        buttons2.add(b4);
+
+        p.add(Box.createRigidArea(VGAP10));
+        p.add(buttons1);
+        p.add(Box.createRigidArea(VGAP15));
+        p.add(buttons2);
+        p.add(Box.createRigidArea(VGAP10));
+
+        palette.getContentPane().add(p, BorderLayout.NORTH);
+
+        // ************************************
+        // * Create frame property checkboxes *
+        // ************************************
+        p = new JPanel();
+        p.setBorder(new EmptyBorder(10, 15, 10, 5));
+        p.setLayout(new GridLayout(1, 2));
+
+
+        Box box = new Box(BoxLayout.Y_AXIS);
+        windowResizable = new JCheckBox(RESIZABLE_LABEL, true);
+        windowIconifiable = new JCheckBox(ICONIFIABLE_LABEL, true);
+
+        box.add(Box.createGlue());
+        box.add(windowResizable);
+        box.add(windowIconifiable);
+        box.add(Box.createGlue());
+        p.add(box);
+
+        box = new Box(BoxLayout.Y_AXIS);
+        windowClosable = new JCheckBox(CLOSABLE_LABEL, true);
+        windowMaximizable = new JCheckBox(MAXIMIZABLE_LABEL, true);
+
+        box.add(Box.createGlue());
+        box.add(windowClosable);
+        box.add(windowMaximizable);
+        box.add(Box.createGlue());
+        p.add(box);
+
+        palette.getContentPane().add(p, BorderLayout.CENTER);
+
+        // ************************************
+        // *   Create Frame title textfield   *
+        // ************************************
+        p = new JPanel();
+        p.setBorder(new EmptyBorder(0, 0, 10, 0));
+
+        windowTitleField = new JTextField(resourceManager.getString("InternalFrameDemo.frame_label"));
+        windowTitleLabel = new JLabel(resourceManager.getString("InternalFrameDemo.title_text_field_label"));
+
+        p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
+        p.add(Box.createRigidArea(HGAP5));
+        p.add(windowTitleLabel, BorderLayout.WEST);
+        p.add(Box.createRigidArea(HGAP5));
+        p.add(windowTitleField, BorderLayout.CENTER);
+        p.add(Box.createRigidArea(HGAP5));
+
+        palette.getContentPane().add(p, BorderLayout.SOUTH);
+
+        palette.show();
+    }
+
+
+    private class CreateFrameAction extends AbstractAction {
+        final InternalFrameDemo demo;
+        final Icon icon;
+
+        public CreateFrameAction(InternalFrameDemo demo, Icon icon) {
+            this.demo = demo;
+            this.icon = icon;
+        }
+
+        public void actionPerformed(ActionEvent e) {
+            demo.createInternalFrame(icon,
+                    DEMO_FRAME_LAYER,
+                    FRAME_WIDTH,
+                    FRAME_HEIGHT
+            );
+        }
+    }
+
+    private static class ImageScroller extends JScrollPane {
+
+        public ImageScroller(Icon icon) {
+            super();
+            JPanel p = new JPanel();
+            p.setBackground(Color.white);
+            p.setLayout(new BorderLayout());
+
+            p.add(new JLabel(icon), BorderLayout.CENTER);
+
+            getViewport().add(p);
+            getHorizontalScrollBar().setUnitIncrement(10);
+            getVerticalScrollBar().setUnitIncrement(10);
+        }
+
+        public Dimension getMinimumSize() {
+            return new Dimension(25, 25);
+        }
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sanity/client/lib/SwingSet3/src/com/sun/swingset3/demos/internalframe/resources/InternalFrameDemo.properties	Mon Aug 27 03:48:41 2018 -0700
@@ -0,0 +1,17 @@
+### Internal Frame Demo ###
+
+InternalFrameDemo.accessible_description=JInternal Frame Demo
+InternalFrameDemo.create_frames_label=Create Customized Internal Frames
+InternalFrameDemo.title_text_field_label=Frame title:
+InternalFrameDemo.frame_label=Frame
+InternalFrameDemo.palette_label=Internal Frame Generator
+InternalFrameDemo.name=Internal Frames Demo
+InternalFrameDemo.tooltip=JInternalFrame demo
+InternalFrameDemo.closable_label=Closable
+InternalFrameDemo.resizable_label=Resizable
+InternalFrameDemo.iconifiable_label=Iconifiable
+InternalFrameDemo.maximizable_label=Maximizable
+InternalFrameDemo.bananas=Go Bananas
+InternalFrameDemo.globe=Spinning Globe
+InternalFrameDemo.package=Gift for you
+InternalFrameDemo.soccerball=Soccer anyone?
\ No newline at end of file
Binary file test/jdk/sanity/client/lib/SwingSet3/src/com/sun/swingset3/demos/internalframe/resources/images/InternalFrameDemo.gif has changed
Binary file test/jdk/sanity/client/lib/SwingSet3/src/com/sun/swingset3/demos/internalframe/resources/images/bananas.png has changed
Binary file test/jdk/sanity/client/lib/SwingSet3/src/com/sun/swingset3/demos/internalframe/resources/images/bananas_small.png has changed
Binary file test/jdk/sanity/client/lib/SwingSet3/src/com/sun/swingset3/demos/internalframe/resources/images/globe.png has changed
Binary file test/jdk/sanity/client/lib/SwingSet3/src/com/sun/swingset3/demos/internalframe/resources/images/globe_small.png has changed
Binary file test/jdk/sanity/client/lib/SwingSet3/src/com/sun/swingset3/demos/internalframe/resources/images/package.png has changed
Binary file test/jdk/sanity/client/lib/SwingSet3/src/com/sun/swingset3/demos/internalframe/resources/images/package_small.png has changed
Binary file test/jdk/sanity/client/lib/SwingSet3/src/com/sun/swingset3/demos/internalframe/resources/images/soccer_ball.png has changed
Binary file test/jdk/sanity/client/lib/SwingSet3/src/com/sun/swingset3/demos/internalframe/resources/images/soccer_ball_small.png has changed