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

RFE: set minimum/maximum size of top-level window

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 1.4.0, 1.4.2
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      linux, windows_xp

      Description

      Name: jk109818 Date: 09/09/2002


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


      FULL OPERATING SYSTEM VERSION :
      SuSE Linux 8.0, Linux Kernel 2.4.18, glibc 2.2.5
       
      ADDITIONAL OPERATING SYSTEMS :


      A DESCRIPTION OF THE PROBLEM :
      Currently, a top-level window doesn't directly honor the
      minimum/maximum size set on e.g. a JFrame.
        
      There is a (ugly) workaround for this problem:
      http://www.javaworld.com/javaworld/javaqa/1999-10/03-qa-window.html
        
      It would be trivial to add the top-level minimum/maximum size
      to the XSetWMNormalHints() call that is done anyway.
       
      On Windows, the WM_GETMINMAXINFO notification could be used to
      enforce the minimum/maximum size.
       
      I know that not all X window managers handle the hint, but almost
      all sane do ;-)


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. create a JFrame with some stuff in it
      2. System.out.println("frame min size should be= "+frame.getMinimumSize());
      3. resize the window


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      I would expect that the window doesn't shrink below its minimum size,
      but it does :-(

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.JPanel;
      import javax.swing.JLabel;
      import javax.swing.JButton;
      import javax.swing.JFrame;
      import javax.swing.WindowConstants;
      import java.awt.GridBagLayout;
      import java.awt.GridBagConstraints;
       
      /**
       * Small test to see the min max proplem
       */
      public class MinMaxTest
      {
          /**
           * Sets the UI up
           * @param args not used
           */
          public static void main(String[] args)
          {
              JPanel panel = new JPanel(new GridBagLayout());
              GridBagConstraints constrain= new GridBagConstraints();
              constrain.gridx = 0;
              constrain.gridy = 0;
              constrain.insets.left = 2;
              constrain.insets.right= 2;
              JLabel label = new JLabel("TestLabel");
              panel.add(label, constrain);
              constrain= new GridBagConstraints();
              constrain.gridx = 1;
              constrain.gridy = 0;
              constrain.fill = GridBagConstraints.HORIZONTAL;
              constrain.weightx= 1.;
              JButton button = new JButton("Testbutton");
              panel.add(button,constrain);
       
              JFrame frame= new JFrame("TestFrame");
              frame.getContentPane().add(panel);
              frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
              frame.pack();
              frame.setVisible(true);
              System.out.println("frame min size= "+frame.getMinimumSize());
          }
      }

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

      CUSTOMER WORKAROUND :
      http://www.javaworld.com/javaworld/javaqa/1999-10/03-qa-window.html
      but ugly as hell ...
      (Review ID: 164198)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                vbaranovsunw Vyacheslav Baranov (Inactive)
                Reporter:
                jkimsunw Jeffrey Kim (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: