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

JRootPane.getMaximumSize() returns a width of 0

    XMLWordPrintable

Details

    • b29
    • x86
    • linux

    Description

      FULL PRODUCT VERSION :
      java version "1.4.2"
      java version "1.5.0"
      java version "1.6.0_03"

      ADDITIONAL OS VERSION INFORMATION :
      Linux, Windows

      A DESCRIPTION OF THE PROBLEM :
      The getMaximumSize() method, applied to a JRootPane instance,
      returns a width of 0. This is smaller than the width returned by
      getMinimumSize() and by getPreferredSize() of the same instance.

      For reference, the maximum size of a JPanel is [2147483647,2147483647]
      (due to the BorderLayout).

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile and run this program:
      ================ bug.java =====================
      import javax.swing.*;

      public class bug {
        public static void main (String args[]) {
          JRootPane r = new JRootPane();
          r.getContentPane().add(new JLabel("foo"));
          System.out.println(r.getMinimumSize());
          System.out.println(r.getPreferredSize());
          System.out.println(r.getMaximumSize());
        }
      }
      ===================================================

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      It should print:
      java.awt.Dimension[width=21,height=15]
      java.awt.Dimension[width=21,height=15]
      java.awt.Dimension[width=2147483647,height=2147483647]

      ACTUAL -
      It prints:
      java.awt.Dimension[width=21,height=15]
      java.awt.Dimension[width=21,height=15]
      java.awt.Dimension[width=0,height=2147483647]


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.*;

      public class bug {
        public static void main (String args[]) {
          JRootPane r = new JRootPane();
          r.getContentPane().add(new JLabel("foo"));
          System.out.println(r.getMinimumSize());
          System.out.println(r.getPreferredSize());
          System.out.println(r.getMaximumSize());
        }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      Use the getContentPane().getMaximumSize() instead of getMaximumSize().

      Attachments

        Activity

          People

            kaddepalli Krishna Addepalli
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: