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

JScrollPane.getMinimumSize().height > JScrollPane.getPreferredSize().height

    XMLWordPrintable

Details

    Description

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

      Solaris
      java version "1.5.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
      Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)


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

      SunOS nzx102 5.9 Generic_112233-07 sun4u sparc SUNW,UltraAX-i2

      A DESCRIPTION OF THE PROBLEM :
      The height of the minimum size is more than the height of the preferred size.


      This is a problem because...

      My LayoutManager expands the layout if the window is larger than the prefered size, but doesn't change the layout when the window is smaller (in each dimension, independantly) than the minimum size. (so if you make the window too small, you just see the upper left corner of the minimally layed out components)

      But this problem means that the packed height of the window is less than the minimum height, so we lay it out at the minimum size and the bottom part of the window is placed (but clipped and not visible) outside the window.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile and run attached code

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      preferred size to be no smaller than minimum size.
      ACTUAL -
      height of preferred size is less than height of minimum size.


      on XP, output is

      notesPane preferred size=java.awt.Dimension[width=223,height=19]
                minimum size=java.awt.Dimension[width=22,height=22]


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.JScrollPane;
      import javax.swing.JTextArea;
      class JScrollPaneSize {
          public static void main(String[] args) {
              JTextArea notes = new JTextArea(0, 20);
              JScrollPane notesPane =
                  new JScrollPane(notes,
                                  // either of the next two values exhibit the bug
                                  // JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                  JScrollPane.VERTICAL_SCROLLBAR_NEVER,
                                  JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
              notes.setText("only 1 line");
              System.out.format(
      "JScrollPane preferred size=%s%n minimum size=%s%n",
                  notesPane.getPreferredSize(),
                  notesPane.getMinimumSize());
          }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      I will need to change my LayoutManager so that the 'smallest layout' is the preferred size, rather than the minimum size.

      The 'smallest layout' is where, as the window shrinks, I stop adjusting the layout to fit the window, and just allow the window to display the top left portion of the contents.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: