Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6690014

JInternalFrame can't be closed, iconified or deiconifed if its parent differs from JDesktopPane

    Details

    • Subcomponent:
    • Introduced In Build:
      b70
    • Introduced In Version:
      6
    • CPU:
      x86
    • OS:
      windows_xp

      Backports

        Description

        FULL PRODUCT VERSION :
        java version "1.6.0_04"
        Java(TM) SE Runtime Environment (build 1.6.0_04-b12)
        Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)

        ADDITIONAL OS VERSION INFORMATION :
        Microsoft Windows XP [Version 5.1.2600]

        A DESCRIPTION OF THE PROBLEM :
        A JInternalFrame added to the layered pane of a JApplet cannot be iconified anymore in Java SE 6.

        I found the problem in the source code, class javax.swing.DefaultDesktopManager, in method iconifyFrame(JInternalFrame f); inside this method, a check for a null Container c only (in Java SE 5) was changed to a check for a null container c OR a null JDesktopPane d:

        if (c == null || d == null) {
            return;
        }

        (line 164 of source code of class javax.swing.DefaultDesktopManager)

        But a JInternalFrame attached to a JApplet will always return "null" for getDesktopPane(), so iconifyFrame method returns in Java SE 6 without performing the actual iconify.


        REPRODUCIBILITY :
        This bug can be reproduced always.

        Release Regression From : 5.0
        The above release value was the last known release where this
        bug was not reproducible. Since then there has been a regression.
        JInternalFrame can't be closed, iconified or deiconifed if its parent differs from JDesktopPane. This behavior doesn't comply the JInternalFrame specs. It is declared that an internal frame can be added to any Container. However, after the fix for 6325652 an internal frame can be closed, iconified or deiconifed only when its parent is JDesktopPane.

        Test case:
        ==== Source Begin ====
        import javax.swing.*;

        public class InternalFrameCloseTest {
            private static JFrame frame;
            private static JInternalFrame iFrame;
            private static boolean testPassed = true;

            public static void main(String[] args) throws Exception {
                SwingUtilities.invokeAndWait(new Runnable() {
                    public void run() {
                        setupUI();
                    }
                });
                SwingUtilities.invokeAndWait(new Runnable() {
                    public void run() {
                        iFrame.dispose();
                    }
                });
                SwingUtilities.invokeAndWait(new Runnable() {
                    public void run() {
                        if (frame.getContentPane().getComponentCount() == 1) {
                            testPassed = false;
                        }
                    }
                });

                try {
                    if (testPassed) {
                        System.out.println("Test passed");
                    } else {
                        throw new RuntimeException("JInternalFrame cannot be " +
                                "properly closed if its parent differs from JDesktopPane");
                    }
                } finally {
                    frame.dispose();
                }
            }

            private static void setupUI() {
                frame = new JFrame();
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

                frame.getContentPane().setLayout(null);
                frame.setSize(400, 300);
                frame.setLocationRelativeTo(null);
                frame.setVisible(true);

                iFrame = new JInternalFrame("Internal frame", true, true, true, true);
                frame.getContentPane().add(iFrame);
                iFrame.setSize(200, 100);
                iFrame.setLocation(50, 50);
                iFrame.setVisible(true);
            }
        }
        ==== Source End ====

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  alexsch Alexandr Scherbatiy
                  Reporter:
                  ndcosta Nelson Dcosta (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: