Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4623407

REGRESSION:JButton problematic in nested JInternalFrames

XMLWordPrintable

    • generic, x86
    • generic, windows_98



      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)
      ======================================================================

            joutwatesunw Joshua Outwater (Inactive)
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: