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

JInternalFrame setDefaultCloseOperation ignored under Motif look-and-feel.

XMLWordPrintable

    • 05
    • x86, sparc
    • solaris_8, windows_2000
    • Verified



        Name: jk109818 Date: 04/17/2003


        FULL PRODUCT VERSION :
        java version "1.4.1_01"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
        Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)


        FULL OS VERSION :
        Problem is OS-independent. I reproduced it under Windows XP and Solaris 8

        A DESCRIPTION OF THE PROBLEM :
        The method "setDefaultCloseOperation()" of JInternalFrame is ignored under Motif Look-and-feel. My attached testcase demonstrates the problem.

        I set the default close operation of a JInternalFrame to "DO_NOTHING_ON_CLOSE", but it is not honored under Motif look-and-feel.

        My application that works under Windows L&F and Metal L&F, does not work properly
        under Motif because of this problem.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Compile and execute the source code of my test case. Double click the upper left corner of the internal frame.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        The expected results is that the double click of the close button of the
        internal frame be ignored.
        The double-clicking of the close button causes the internal frame to close, even though the default close operation was set to "DO_NOTHING_ON_CLOSE".

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import javax.swing.*;
        import javax.swing.event.*;

        /**
         * Demonstrates bug:
         * "setDefaultCloseOperation()" ignored for JInternalFrame under Motif.
         */
        class Test {

            public static void main(String args[]){
                try {
                    UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
                }
                catch(Exception x){
                    System.err.println("Can't switch to Motif Look and Feel");
                    System.exit(1);
                }

                JFrame f = new JFrame("Test");
                JDesktopPane pane = new JDesktopPane();
                f.setContentPane(pane);
                JInternalFrame iframe = new JInternalFrame("InternalFrame");
                iframe.setDefaultCloseOperation(JInternalFrame.DO_NOTHING_ON_CLOSE);
                iframe.addInternalFrameListener(new InternalFrameAdapter(){
                     public void internalFrameClosed(InternalFrameEvent e){
                         System.err.println("Hey! Not suppose to close!!!");
                         }
                     });
                iframe.setClosable(true);

                iframe.setSize(300,300);
                iframe.show();

                pane.add(iframe);
                f.setSize(500,500);
                f.show();
            }
        }
        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        The only work-around that I know of is to veto the "closed" property change on the JInternalFrame.

        The cause of the bug can be readily seen in the source to:

        com.sun.java.swing.plaf.motif.MotifInternalFrameTitlePane

        Look for:

                systemButton.addMouseListener(new MouseAdapter() {
                    public void mousePressed(MouseEvent e) {
                                        if ((e.getClickCount() == 2)){
                                                if (iFrame.isClosable()) {
                                                        try{
                                                                iFrame.setClosed(true);
                                                        } catch (PropertyVetoException e0) { }
                                                }
                                                systemMenu.setVisible(false);
                                        }
                                }
                        });


        Change the statement "iFrame.setClosed(true)" to
        "iFrame.doDefaultCloseAction()".
        (Review ID: 184329)
        ======================================================================

              joutwatesunw Joshua Outwater (Inactive)
              jkimsunw Jeffrey Kim (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: