-
Bug
-
Resolution: Fixed
-
P4
-
1.3.1_06, 1.4.1, 1.4.1_02, 1.4.2
-
05
-
x86, sparc
-
solaris_8, windows_2000
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2068366 | 5.0 | Joshua Outwater | P4 | Resolved | Fixed | tiger |
JDK-2068365 | 1.4.2_02 | Joshua Outwater | P4 | Resolved | Fixed | 02 |
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)
======================================================================
- backported by
-
JDK-2068365 JInternalFrame setDefaultCloseOperation ignored under Motif look-and-feel.
- Resolved
-
JDK-2068366 JInternalFrame setDefaultCloseOperation ignored under Motif look-and-feel.
- Resolved