Bug with JInternalFrame

I think I may have discovered a bug.

I googled the bug database with "java bug jinternalframe maximize"

and didnt find it addressed. (But then again I can never find obvious

bugs in the database).

Platform:

win xp prof, java 6, system look and feel

Bug:

I have a simple JFrame with the content pane set to a Desktop.

I add 2 JInternalFrames to the desktop.

All JIF attributes (closeable, resize, etc) set to true.

Neither JIFs are maximized.

If I maximize JIF#1 and then close it JIF#2 becomes maximized

underneath!

If I minimize or restore JIF#1 instead of closing everything is as expected (JIF#2 is the same size it was underneath).

If this isnt already an identified bug (though im sure it is)

I can whip up an example i guess.

This happens in any program with a Desktop and JIFs.

Thanks.

[905 byte] By [TuringPesta] at [2007-11-26 15:53:08]
# 1

This doesn't do that, see if it's similar to what you have.

public class NewJFrame extends javax.swing.JFrame

{

private javax.swing.JDesktopPane jDesktopPane1;

private javax.swing.JInternalFrame jInternalFrame1;

private javax.swing.JInternalFrame jInternalFrame2;

public NewJFrame()

{

jDesktopPane1 = new javax.swing.JDesktopPane();

jInternalFrame1 = new javax.swing.JInternalFrame();

jInternalFrame2 = new javax.swing.JInternalFrame();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

setMinimumSize(new java.awt.Dimension(500, 300));

jInternalFrame1.setIconifiable(true);

jInternalFrame1.setMaximizable(true);

jInternalFrame1.setResizable(true);

jInternalFrame1.setTitle("JIF1");

jInternalFrame1.setVisible(true);

jInternalFrame1.setBounds(50, 40, 110, 120);

jDesktopPane1.add(jInternalFrame1, javax.swing.JLayeredPane.DEFAULT_LAYER);

jInternalFrame2.setIconifiable(true);

jInternalFrame2.setMaximizable(true);

jInternalFrame2.setResizable(true);

jInternalFrame2.setTitle("JIF2");

jInternalFrame2.setVisible(true);

jInternalFrame2.setBounds(230, 40, 110, 120);

jDesktopPane1.add(jInternalFrame2, javax.swing.JLayeredPane.DEFAULT_LAYER);

getContentPane().add(jDesktopPane1, java.awt.BorderLayout.CENTER);

pack();

}

public static void main(String args[])

{

java.awt.EventQueue.invokeLater(new Runnable()

{

public void run()

{

new NewJFrame().setVisible(true);

}

});

}

}

ChuckBinga at 2007-7-8 22:13:34 > top of Java-index,Desktop,Core GUI APIs...
# 2
Well the problem is with closing the JIF. So i added setClosable(true) to both.But youre right, I didnt get the problem.Ill try to make time now to whip up an example.Thanks
TuringPesta at 2007-7-8 22:13:34 > top of Java-index,Desktop,Core GUI APIs...
# 3

Here you go. I DO get the bug with the following code. I didnt get the bug with the Java LAFbut when I

added the LAF change code I got the bug (which

leads me to believe its a Windows LAF bug?).

Maximize either JIF and then close it with the X close button. Voila, the other JIF will be maximized behind it.

import javax.swing.*;

import javax.swing.event.*;

import java.awt.*;

import java.awt.event.*;

public class BugTest{

public static void main(String[] args) {

new BugTest();

}

public BugTest(){

try{

String laf = UIManager.getSystemLookAndFeelClassName();

UIManager.setLookAndFeel(laf);

}catch(Exception e){

e.printStackTrace();

}

frame = new JFrame("Bug Test");

desktop = new JDesktopPane();

jif1 = new JIF("JIF #1");

jif2 = new JIF("JIF #2");

frame.setContentPane(desktop);

frame.setExtendedState(JFrame.MAXIMIZED_BOTH);

frame.setVisible(true);

}

public class JIF extends JInternalFrame{

public JIF(String title){

super(title, true, true, true, true);

setSize(400, 300);

setLocation(100, 200);

addToDesktop();

this.setVisible(true);

}

public void addToDesktop(){

desktop.add(this);

try{

this.setSelected(true);

}catch(java.beans.PropertyVetoException e){

e.printStackTrace();

}

}

}

JFrame frame;

JDesktopPane desktop;

JIF jif1;

JIF jif2;

}

TuringPesta at 2007-7-8 22:13:34 > top of Java-index,Desktop,Core GUI APIs...
# 4
Doesn't work on JDK1.4.2 either.I would say its a bug.
camickra at 2007-7-8 22:13:34 > top of Java-index,Desktop,Core GUI APIs...
# 5
Woo hoo. I found a bug. Do they name it after you? ; )
TuringPesta at 2007-7-8 22:13:34 > top of Java-index,Desktop,Core GUI APIs...
# 6
> Woo hoo. I found a bug. Do they name it after you? ; ) Only if they actually fix it.
camickra at 2007-7-8 22:13:34 > top of Java-index,Desktop,Core GUI APIs...
# 7

> Woo hoo. I found a bug. Do they name it after you? ; )

I don't want to rain on your parade, but this sounds very much like a manifestation of this bug:

[url http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5036083]5036083[/url]

:-) The bug report says it has been fixed in mustang (Java 6), but I haven't tried it yet.

Also note the following lines from the bug evaluation:

"Windows internal frames have this behavior by design. It is done this way to match the behavior of the native Windows platform. From the documentation to com.sun.java.swing.plaf.windows.WindowsDesktopManager:

* The maximized state is managed by the DesktopManager with MDI,

* instead of just being a property of the individual child frame.

* This means that if the currently selected window is maximized

* and another window is selected, that new window will be maximized."

Torgila at 2007-7-8 22:13:34 > top of Java-index,Desktop,Core GUI APIs...
# 8
> Windows internal frames have this behavior by design....Cool, I never noticed that behaviour behaviour but I just tested it out on Word and sure enough that is the standard behaviour.I change my vote. Its a Windows feature, not a bug.
camickra at 2007-7-8 22:13:34 > top of Java-index,Desktop,Core GUI APIs...
# 9
It misbehaves for me on Java 6 when the setClosable and LAF is added to my original code. Looks buggy to me.
ChuckBinga at 2007-7-8 22:13:34 > top of Java-index,Desktop,Core GUI APIs...
# 10

> > Windows internal frames have this behavior by

> design....

>

> Cool, I never noticed that behaviour behaviour but I

> just tested it out on Word and sure enough that is

> the standard behaviour.

>

> I change my vote. Its a Windows feature, not a bug.

I must admit I found the behavior of TuringPest's demo program unintuitive, but I agree, if this is the standard behavior for windows applications then it's not a bug.

Torgila at 2007-7-8 22:13:34 > top of Java-index,Desktop,Core GUI APIs...
# 11

> It misbehaves for me on Java 6 when the setClosable

> and LAF is added to my original code. Looks buggy to

> me.

Note that the bug report talks about two different cases:

1. Two internal frames. One is maximized, then closed. The expected behavior on windows is that the second internal frame should be maximized.

2. Two internal frames. One is maximized, then minimized. The expected behavior is that the second internal frame should not be maximized.

The first case is what TuringPest mentions, and that is apparently not a bug since that is the way window applications are expected to work. The bug report I linked to dealt with the second case, namely that the second frame remained maximized even after the first frame was minimized (not closed).

Torgila at 2007-7-8 22:13:34 > top of Java-index,Desktop,Core GUI APIs...
# 12
Yes, our replies crossed - I have now read the bug description and what it says should be happening is happening in Java 6 - so. . .
ChuckBinga at 2007-7-8 22:13:34 > top of Java-index,Desktop,Core GUI APIs...
# 13
> I change my vote. Its a Windows feature, not a bug.Oh lord, thats what I was afraid of.As always, thanks Windows!p.s. - im starting a petition to add a disableGoofyWindows"Feature"() method to JDesktopPane : )Itll be the first method name to include
TuringPesta at 2007-7-8 22:13:34 > top of Java-index,Desktop,Core GUI APIs...