JDK-4515083 : java.awt.GridLayout.minimumLayoutSize doesn't comply to spec
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.0,5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,solaris_2.5
  • CPU: generic,sparc
  • Submitted: 2001-10-16
  • Updated: 2017-05-16
  • Resolved: 2003-11-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0 betaFixed
Related Reports
Relates :  
Description

Name: bkR10101			Date: 10/16/2001



Specification for public Dimension minimumLayoutSize(Container parent):
"Determines the minimum size of the container argument using this grid 
layout. The minimum width of a grid layout is the largest minimum width 
of any of the widths in the container times the number of columns, plus 
the horizontal padding times the number of columns plus one, plus the 
left and right insets of the target container. The minimum height of a 
grid layout is the largest minimum height of any of the heights in the 
container times the number of rows, plus the vertical padding times 
the number of rows plus one, plus the top and bottom insets of the 
target container".

Sample code:
====================== minimumLS.java ===============================
import java.awt.*;

public class minimumLS {

    public static void main(String argv[]) {
        int rows = 1; int cols = 2; 

        int hgap = 2; int vgap = 3;

        GridLayout gl = new GridLayout(rows, cols, hgap, vgap);
  
        Container parent = new Container();
        parent.setLayout(gl);
        parent.setSize(100, 200);

        Insets insets = parent.getInsets();
        System.out.println("Insets left " + insets.left + " right " +
                           insets.right + " top " + insets.top + 
                           " bottom " + insets.bottom);

        Component comp = new Component(){};
        comp.setSize(13, 24);

        parent.add(comp, "comp");
        System.out.println("comp min size " + comp.getMinimumSize());

        Component comp2 = new Component(){};
        comp2.setSize(19, 11);

        parent.add(comp2, "comp2");
        System.out.println("comp2 min size " + comp2.getMinimumSize());

        Dimension dim = gl.minimumLayoutSize(parent);
        System.out.println("minimum layout size " + dim);
    }
}
==================== end of minimumLS.java ===============================
Output under JDK version "1.4.0-beta3-b81" ===============================
~/bugs
java minimumLS
Insets left 0 right 0 top 0 bottom 0
comp min size java.awt.Dimension[width=13,height=24]
comp2 min size java.awt.Dimension[width=19,height=11]
minimum layout size java.awt.Dimension[width=40,height=24]
~/bugs
==========================================================================
So first was created GridLayout with 1 row and 2 columns. Its hgap was 
set to 2 and vgap was set to 3. Then created parent container. Then two
components were added to container. Sizes of components are (13, 24) and 
(19, 11).

Minimum layout size returned by gl.minimumLayoutSize(parent):
[width=40,height=24], it is not equal one according specification.

Minimum layout size according specification is 
width : max(13, 19) * 2 + 2 * (2+1) + 0 + 0 = 38 + 6 = 44
height : max(24, 11) * 1 + 3 * (1+1) + 0 + 0 = 24 + 6 = 30

======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger-beta FIXED IN: tiger-beta INTEGRATED IN: tiger-beta VERIFIED IN: tiger
14-06-2004

SUGGESTED FIX ------- GridLayout.java ------- *** /tmp/dhQaONU Wed May 29 19:58:51 2002 --- GridLayout.java Wed May 29 19:58:44 2002 *************** *** 329,340 **** * <p> * The minimum width of a grid layout is the largest minimum width * of any of the components in the container times the number of columns, ! * plus the horizontal padding times the number of columns plus one, * plus the left and right insets of the target container. * <p> * The minimum height of a grid layout is the largest minimum height * of any of the components in the container times the number of rows, ! * plus the vertical padding times the number of rows plus one, plus * the top and bottom insets of the target container. * * @param target the container in which to do the layout --- 329,340 ---- * <p> * The minimum width of a grid layout is the largest minimum width * of any of the components in the container times the number of columns, ! * plus the horizontal padding times the number of columns minus one, * plus the left and right insets of the target container. * <p> * The minimum height of a grid layout is the largest minimum height * of any of the components in the container times the number of rows, ! * plus the vertical padding times the number of rows minus one, plus * the top and bottom insets of the target container. * * @param target the container in which to do the layout
11-06-2004

EVALUATION Commit to fix in Tiger (spec issue that affects TCK). ###@###.### 2002-05-29
29-05-2002