JDK-4623407 : REGRESSION:JButton problematic in nested JInternalFrames
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic,windows_98
  • CPU: generic,x86
  • Submitted: 2002-01-14
  • Updated: 2005-06-11
  • Resolved: 2005-06-11
Related Reports
Duplicate :  
Description

Name: rmT116609			Date: 01/14/2002


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


A DESCRIPTION OF THE PROBLEM :
Buttons in nested JInternalFrames do not work the first time they are clicked. Rather the buttons require multiple
clicks depending on how deep the internal frames are nested. For example, for an internal frame within one
internal frame, I need to click a button twice in order to actvate the "actionPerformed". If I add another nested
internal frame, I need to click the button 3 times, etc.

This bug is in 1.4.0-beta3 but not in 1.3.1.

REGRESSION.  Last worked in version 1.3.1

The problem is reproducible on Windows 2000, Solaris 2.8, Linux Redhat 6.1 using 1.4.0-beta3.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.Run the attached program (there are 2 classes).
2.Click the button "Add Nested Frame"
3.In the nested frame, click the button "Add Nested Frame"
4. etc.


EXPECTED VERSUS ACTUAL BEHAVIOR :
The button requires progressively more clicks in order to invoke the "actionPerformed" - which is not what one expects.

This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.JInternalFrame;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;

import java.awt.event.*;
import java.awt.*;

public class InternalFrameDemo extends JFrame {
    JDesktopPane desktop;

    public InternalFrameDemo() {
        super("InternalFrameDemo");

        //Make the big window be indented 50 pixels from each edge
        //of the screen.
        int inset = 50;
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        setBounds(inset, inset,
                  screenSize.width - inset*2,
                  screenSize.height-inset*2);

        //Quit this app when the big window closes.
        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });

        //Set up the GUI.
        desktop = new JDesktopPane(); //a specialized layered pane
        createFrame(); //Create first window
        setContentPane(desktop);

        //Make dragging faster:
        desktop.putClientProperty("JDesktopPane.dragMode", "outline");
    }


    protected void createFrame() {
        MyNestedFrame frame = new MyNestedFrame();
        desktop.add(frame);
        frame.setVisible(true);
   }

    public static void main(String[] args) {
        InternalFrameDemo frame = new InternalFrameDemo();
        frame.setVisible(true);
    }
}

import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

public class MyNestedFrame extends JInternalFrame {
    static int openFrameCount = 0;
    static final int xOffset = 10, yOffset = 10;

    private JInternalFrame thisFrame;

    public MyNestedFrame() {
        super("Nested Frame #" + (++openFrameCount),
              true, //resizable
              true, //closable
              true, //maximizable
              true);//iconifiable

      thisFrame = this;
      System.out.println("in constructor of MyNestedFrame # " + openFrameCount);

        //...Create the GUI and put it in the window...
      JPanel contentPane = new JPanel();
      setContentPane(contentPane);
      contentPane.setLayout(new BorderLayout());
      JButton button = new JButton("Add Nested Frame");
      contentPane.add(button, BorderLayout.NORTH);
      button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          MyNestedFrame nestedFrame = new MyNestedFrame();
          thisFrame.getLayeredPane().add(nestedFrame);
          nestedFrame.setVisible(true);
        }
      });

        //...Then set the window size or call pack...
        setSize(500,500);

        //Set the window's location.
        setLocation(xOffset*openFrameCount, yOffset*openFrameCount);
    }
}

---------- END SOURCE ----------
(Review ID: 138278) 
======================================================================

Comments
EVALUATION I am able to reproduce this, but this never fully worked under 1.3.1 either. Under 1.3.1 any internal frame that is nested can not be moved or resized. This is related to the mouse forwarding code in BasicInternalFrameUI.java. We do not recommend that developers use nested internal frames. We will target this for the next major realese. ###@###.### 2002-01-16 The bug is reproducible in 1.6.0-ea-b33. The bug is not reproducible in 1.6.0-ea-b34 and later builds. Most likely it was fixed by my fix for 4302764: focus is not set in JInternalFrame Closing as duplicate of 4302764. ###@###.### 2005-06-11 01:25:16 GMT
11-06-2005