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

REGRESSION: JInternalFrame.setMaximum(true) unreliable.

XMLWordPrintable

    • beta
    • x86
    • windows_xp



      Name: gm110360 Date: 07/12/2004


      FULL PRODUCT VERSION :
      java version "1.5.0-beta2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b51)
      Java HotSpot(TM) Client VM (build 1.5.0-beta2-b51, mixed mode, sharing)


      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]


      A DESCRIPTION OF THE PROBLEM :
      Calling JInternalFrame.setMaximum(true) sometimes toggles the maximum state, rather than turning it on. setMaximum(true) should never turn the maximum state off. The problem is compounded by the fact that there is no getMaximum() method (in violation of getter/setter conventions), so I can't fix the problem by reading the Maximum property first.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run Sample program under JDK 1.5beta2. (Compare by running it under JDK 1.4.2)
      Hit the "Cycle" button to cycle to the last internal frame and maximize it.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The button should cycle to the last internal frame (which it does), and should maximize that frame, regardless of its previous state (which it doesn't always do).

      ACTUAL -
      It only maximized the new window if it wasn't maximized before. If it was maximized, it performs a restore, which is normally done by calling setMaximum(false);

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.BorderLayout;
      import java.awt.GridLayout;
      import java.awt.event.ActionListener;
      import java.awt.event.ActionEvent;
      import java.beans.PropertyVetoException;

      import javax.swing.JFrame;
      import javax.swing.JPanel;
      import javax.swing.JDesktopPane;
      import javax.swing.JLabel;
      import javax.swing.JInternalFrame;
      import javax.swing.UIManager;
      import javax.swing.JButton;

      public class InternalFrameBug
          extends JPanel
      {
        private static JFrame mf;
        private JDesktopPane mDesk;

        public static void main(String[] args)
        {
          try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); }
          catch (Exception e) { e.printStackTrace(); }
          mf=new JFrame("JInternalFrame Maximize Bug");
          mf.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
          InternalFrameBug view=new InternalFrameBug();
          mf.getContentPane().setLayout(new BorderLayout());
          mf.getContentPane().add(view, BorderLayout.CENTER);
          mf.setBounds(10, 10, 600, 400);
          mf.setVisible(true);
        }

        private InternalFrameBug()
        {
          super(new BorderLayout());
          String[] names = { "One", "Two", "Three", "Four", "Five" };
          // For some reason, this bug only shows up with multiple windows.
          // If I replace the line above with the line below, the bug goes away.
          // Consequently, it may have something to do with switching the windows.
      // String[] names = { "One" };
          
          mDesk=new JDesktopPane();
          add(mDesk, BorderLayout.CENTER);
          for (int ii=0; ii<names.length; ++ii)
          {
            JLabel lbl = new JLabel(names[ii]);
            lbl.setFont(lbl.getFont().deriveFont(48.0F));
            JInternalFrame ifr = new JInternalFrame(names[ii], true, true, true, true);
            ifr.setVisible(true);
            ifr.getContentPane().add(lbl);
            ifr.pack();
            
            mDesk.add(ifr);
            System.out.println(names[ii]);
          }
          
          JPanel topPanel = new JPanel(new GridLayout(1, 0));
          JButton cycleBtn = new JButton("Cycle");
          ActionListener al = new ActionListener()
          {
            public void actionPerformed(ActionEvent e)
            {
              JInternalFrame chosen = mDesk.getAllFrames()[mDesk.getComponentCount()-1];
              chosen.moveToFront();
              mDesk.setSelectedFrame(chosen);
              try { chosen.setMaximum(true); }
              catch (PropertyVetoException pve) { pve.printStackTrace(); }
            }
          };
          cycleBtn.addActionListener(al);
          topPanel.add(cycleBtn);
          add(topPanel, BorderLayout.NORTH);
        }
      }

      ---------- END SOURCE ----------

      Release Regression From : 1.4.2
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

      (Incident Review ID: 285638)
      ======================================================================

            mbronsonsunw Mike Bronson (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: