JDK-6459115 : REGRESSION: JInternalFrame within JInternalFrame Drawing Problems
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_10
  • CPU: sparc
  • Submitted: 2006-08-10
  • Updated: 2011-03-08
  • Resolved: 2011-03-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u4Fixed 7 b15Fixed
Description
FULL PRODUCT VERSION :
Java(TM) SE Runtime Environment (build 1.6.0-rc-b94)

A DESCRIPTION OF THE PROBLEM :
If a JDesktopPane is filled with JInternalFrames and the JInternalFrames themselves hold a JDesktopPane with JInternalFrames two things appear to be occuring when a another JInternalFrame is dragged in front of the nested JInternalFrames and the user selects a nested one:
1. Drawing of the nested JInternalFrame contains the dragged over JInternalFrame
2. The dragged over JInternalFrame does not go to the bottom of the frames

This appears to not be the case in Java 5

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run this test:
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.io.*;

public class JInternalFrameInJInternalFrame implements Runnable{

    JFrame jf;
    public void run(){
        jf = new JFrame();
        JDesktopPane jdp = new JDesktopPane();
        jf.add(jdp);
        JInternalFrame one = new JInternalFrame();
        one.setMaximizable(true);
        one.add(new JTextArea());
        one.setSize(200,200);
        jdp.add(one);

        JInternalFrame two = new JInternalFrame();
        two.setResizable(true);
        JDesktopPane jdp2 = new JDesktopPane();
        two.add(jdp2);
        two.setMaximizable(true);
        two.setClosable(true);
        two.setIconifiable(true);
        two.setSize(300,300);
        JInternalFrame three = new JInternalFrame();
        three.add(new JTextField(15));
        three.setMaximizable(true);
        three.setSize(200,200);
        JInternalFrame three_2 = new JInternalFrame();
        three_2.add(new JLabel("Not docking"));
        three_2.setMaximizable(true);
        three_2.setSize(200,200);
        jdp2.add(three_2);
        jdp2.add(three);
        three.setVisible(true);
        three_2.setVisible(true);
        jdp.add(two);
        one.setVisible(true);
        two.setVisible(true);
        JInternalFrame four = new JInternalFrame();
        four.add(new JButton("Not Docking"));
        four.setMaximizable(true);
        four.setSize(200,200);
        jdp.add(four);
        four.setVisible(true);
        jf.setSize(600,600);
        jf.setLocationRelativeTo(null);
        jf.setVisible(true);

    }

    public static void main(String[] args){
        if(args.length > 0){
	    try{
		int i = Integer.parseInt(args[0]);
                if(i == 0) UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                else if(i == 1) UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");

            }catch(Exception x){}

        }
        SwingUtilities.invokeLater(new JInternalFrameInJInternalFrame());

    }


}
---------
Drag a JIF over a JIF with nested JIFs.  Select one of the nested JIFS and drag it around.  You will see that it isn't drawn right, nor is it the dragged over frame moved below the frames.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The nested JIFs mother frame to be the top frame, the dragged over frame to go below it and the nested JIFs to be drawn right.
ACTUAL -
1. JIF's parent isn't the top JIF
2. JIF isn't drawn right
3. Dragged over JIF isn't drawn right as well if dragged afterwords

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.io.*;

public class JInternalFrameInJInternalFrame implements Runnable{

    JFrame jf;
    public void run(){
        jf = new JFrame();
        JDesktopPane jdp = new JDesktopPane();
        jf.add(jdp);
        JInternalFrame one = new JInternalFrame();
        one.setMaximizable(true);
        one.add(new JTextArea());
        one.setSize(200,200);
        jdp.add(one);

        JInternalFrame two = new JInternalFrame();
        two.setResizable(true);
        JDesktopPane jdp2 = new JDesktopPane();
        two.add(jdp2);
        two.setMaximizable(true);
        two.setClosable(true);
        two.setIconifiable(true);
        two.setSize(300,300);
        JInternalFrame three = new JInternalFrame();
        three.add(new JTextField(15));
        three.setMaximizable(true);
        three.setSize(200,200);
        JInternalFrame three_2 = new JInternalFrame();
        three_2.add(new JLabel("Not docking"));
        three_2.setMaximizable(true);
        three_2.setSize(200,200);
        jdp2.add(three_2);
        jdp2.add(three);
        three.setVisible(true);
        three_2.setVisible(true);
        jdp.add(two);
        one.setVisible(true);
        two.setVisible(true);
        JInternalFrame four = new JInternalFrame();
        four.add(new JButton("Not Docking"));
        four.setMaximizable(true);
        four.setSize(200,200);
        jdp.add(four);
        four.setVisible(true);
        jf.setSize(600,600);
        jf.setLocationRelativeTo(null);
        jf.setVisible(true);

    }

    public static void main(String[] args){
        if(args.length > 0){
	    try{
		int i = Integer.parseInt(args[0]);
                if(i == 0) UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                else if(i == 1) UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");

            }catch(Exception x){}

        }
        SwingUtilities.invokeLater(new JInternalFrameInJInternalFrame());

    }


}
---------- END SOURCE ----------

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.

Comments
EVALUATION Contribution forum : https://jdk-collaboration.dev.java.net/servlets/ProjectForumMessageView?forumID=1463&messageID=14842
17-08-2006

SUGGESTED FIX --- src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java *************** *** 2259,2265 **** // Activate the frame. try { ((JInternalFrame)parent).setSelected(true); } catch (PropertyVetoException e1) { } - break; } parent = parent.getParent(); } --- 2259,2264 ----
15-08-2006

EVALUATION On MOUSE_PRESSED, activate the JInternalFrame's all the way up the hierarchy. Remove the 'break;' in BasicLookAndFeel.AWTEventHelper.eventDispatched. See Suggested Fix.
15-08-2006

EVALUATION Not reproducible in 1.6.0-ea-b45 on Windows. Is reproducible in 1.6.0-ea-b46 on Windows. It could be related to this fix which went into b46: 4398733: MouseClicked event not delivered when switched between 2 Internal frames The mouse pressed event that causes JInternalFrame activation may not be propagating up from the JInternalFrame inside a JDesktopPane inside a JInternalFrame inside another JDesktopPane. ----- On Mon, 14 Aug 2006 ###@###.### wrote: While this seems like an odd test case, I don't see any reason why it shouldn't be supported. As such, this is a valid regression. I wouldn't consider it a showstopper right now, and therefore I'd suggest requesting a waiver. But I suggest we investigate and fix it as soon as possible. -----
12-08-2006