Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4850369
Votes 0
Synopsis JInternalFrame setDefaultCloseOperation ignored under Motif look-and-feel.
Category java:classes_swing
Reported Against 1.4.1 , 1.3.1_06 , 1.4.1_02 , mantis-beta
Release Fixed 1.4.1_05
State 10-Fix Delivered, Verified, bug
Priority: 4-Low
Related Bugs
Submit Date 17-APR-2003
Description




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) 
======================================================================
Work Around
N/A
Evaluation
The mouse listener on the system button should be calling the
doDefaultCloseOperation and not setClosed.
 xxxxx@xxxxx  2003-04-24

Shannon had a better idea to have it use CloseAction instead.  Now if developers
subclass CloseAction we will pick up their changes.
 xxxxx@xxxxx  2003-08-29
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang