java.awt.GridLayout bugs (kaffe 1.0.b1)
Giles Lean
giles at nemeton.com.au
Mon Jul 27 07:03:15 PDT 1998
[Seems like PR'd bugs don't get copied to the list ... yell if bug
postings here are unwelcome.]
GridLayout has a couple of problems, the first a minor nit:
Line 105:
c.setBounds( x, y, cw-hgap, ch-hgap);
should presumably be:
c.setBounds( x, y, cw-hgap, ch-vgap);
(i.e. the second "hgap" should be "vgap").
More interestingly, the 1.0.b1 implementation doesn't support leaving
rows or columns as zero. Below is a diff to provide this.
Giles
*** kaffe-1.0.b1-dist/libraries/javalib/java/awt/GridLayout.java Tue Jul 14 14:34:38 1998
--- kaffe-1.0.b1/libraries/javalib/java/awt/GridLayout.java Mon Jul 27 23:09:07 1998
***************
*** 29,34 ****
--- 29,36 ----
}
public GridLayout (int rows, int cols, int hgap, int vgap) {
+ if ( rows == 0 && cols == 0)
+ throw new IllegalArgumentException("GridLayout rows and cols cannot both be zero");
this.rows = rows;
this.cols = cols;
this.hgap = hgap;
***************
*** 40,53 ****
Dimension adjustDim ( Container parent) {
Dimension d = new Dimension( cols, rows);
!
! boolean extCol = true;
! while ( parent.nChildren > d.width * d.height ) {
! if ( extCol ) d.width++;
! else d.height++;
! extCol = !extCol;
}
!
return d;
}
--- 42,71 ----
Dimension adjustDim ( Container parent) {
Dimension d = new Dimension( cols, rows);
!
! if ( rows == 0 ) {
! d.width = cols;
! d.height = parent.nChildren / cols;
! if (parent.nChildren % cols != 0)
! d.height++;
}
! else if ( cols == 0 ) {
! d.height = rows;
! d.width = parent.nChildren / rows;
! if (parent.nChildren % rows != 0)
! d.width++;
! }
! else {
! boolean extCol = true;
! while ( parent.nChildren > d.width * d.height ) {
! if ( extCol )
! d.width++;
! else
! d.height++;
! extCol = !extCol;
! }
! }
!
return d;
}
More information about the kaffe
mailing list