Hi, On Fri, 2006-03-10 at 16:02 -0500, Lillian Angel wrote: > 2006-03-10 Lillian Angel <[EMAIL PROTECTED]> > > * java/awt/GridBagLayout.java > (ArrangeGrid): Added checks to determine if component > is placed last in a row or column. If so, the location > of the last component should be used to get the location > of the current component.
You attached the wrong diff. Attached is the actual patch that was committed. For those reading at home, the actual change is a little obscured by the reindenting of the for loop, but the actual change is just the addition and checking of the lastComponent var. Cheers, Mark
Index: java/awt/GridBagLayout.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/awt/GridBagLayout.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- java/awt/GridBagLayout.java 10 Mar 2006 20:05:56 -0000 1.26
+++ java/awt/GridBagLayout.java 10 Mar 2006 21:01:38 -0000 1.27
@@ -349,105 +349,121 @@
// be invalidated, clearing the layout information cache,
// layoutInfo. So we wait until after this for loop to set
// layoutInfo.
- for(int i = 0; i < components.length; i++)
- {
- Component component = components [i];
-
- // If component is not visible we dont have to care about it.
- if (!component.isVisible())
- continue;
-
- GridBagConstraints constraints =
- lookupInternalConstraints(component);
- int cellx = sumIntArray(info.colWidths, constraints.gridx);
- int celly = sumIntArray(info.rowHeights, constraints.gridy);
- int cellw = sumIntArray(info.colWidths,
- constraints.gridx + constraints.gridwidth) - cellx;
- int cellh = sumIntArray(info.rowHeights,
- constraints.gridy + constraints.gridheight) - celly;
-
- Insets insets = constraints.insets;
- if (insets != null)
- {
- cellx += insets.left;
- celly += insets.top;
- cellw -= insets.left + insets.right;
- cellh -= insets.top + insets.bottom;
- }
-
- Dimension dim = component.getPreferredSize();
-
- // Note: Documentation says that padding is added on both sides, but
- // visual inspection shows that the Sun implementation only adds it
- // once, so we do the same.
- dim.width += constraints.ipadx;
- dim.height += constraints.ipady;
-
- switch(constraints.fill)
- {
- case GridBagConstraints.HORIZONTAL:
- dim.width = cellw;
- break;
- case GridBagConstraints.VERTICAL:
- dim.height = cellh;
- break;
- case GridBagConstraints.BOTH:
- dim.width = cellw;
- dim.height = cellh;
- break;
- }
-
- int x = 0;
- int y = 0;
-
- switch(constraints.anchor)
- {
- case GridBagConstraints.NORTH:
- x = cellx + (cellw - dim.width) / 2;
- y = celly;
- break;
- case GridBagConstraints.SOUTH:
- x = cellx + (cellw - dim.width) / 2;
- y = celly + cellh - dim.height;
- break;
- case GridBagConstraints.WEST:
- x = cellx;
- y = celly + (cellh - dim.height) / 2;
- break;
- case GridBagConstraints.EAST:
- x = cellx + cellw - dim.width;
- y = celly + (cellh - dim.height) / 2;
- break;
- case GridBagConstraints.NORTHEAST:
- x = cellx + cellw - dim.width;
- y = celly;
- break;
- case GridBagConstraints.NORTHWEST:
- x = cellx;
- y = celly;
- break;
- case GridBagConstraints.SOUTHEAST:
- x = cellx + cellw - dim.width;
- y = celly + cellh - dim.height;
- break;
- case GridBagConstraints.SOUTHWEST:
- x = cellx;
- y = celly + cellh - dim.height;
- break;
- default:
- x = cellx + (cellw - dim.width) / 2;
- y = celly + (cellh - dim.height) / 2;
- break;
- }
- component.setBounds(info.pos_x + x, info.pos_y + y, dim.width, dim.height);
- }
-
- // DEBUG
- //dumpLayoutInfo (info);
+ Component lastComp = null;
+ int cellx = 0;
+ int celly = 0;
+ int cellw = 0;
+ int cellh = 0;
+ for (int i = 0; i < components.length; i++)
+ {
+ Component component = components[i];
- // Cache layout information.
- layoutInfo = getLayoutInfo (parent, PREFERREDSIZE);
- }
+ // If component is not visible we dont have to care about it.
+ if (! component.isVisible())
+ continue;
+
+ Dimension dim = component.getPreferredSize();
+ GridBagConstraints constraints = lookupInternalConstraints(component);
+
+ if (lastComp != null
+ && constraints.gridheight == GridBagConstraints.REMAINDER)
+ celly += cellh;
+ else
+ celly = sumIntArray(info.rowHeights, constraints.gridy);
+
+ if (lastComp != null
+ && constraints.gridwidth == GridBagConstraints.REMAINDER)
+ cellx += cellw;
+ else
+ cellx = sumIntArray(info.colWidths, constraints.gridx);
+
+ cellw = sumIntArray(info.colWidths, constraints.gridx
+ + constraints.gridwidth) - cellx;
+ cellh = sumIntArray(info.rowHeights, constraints.gridy
+ + constraints.gridheight) - celly;
+
+ Insets insets = constraints.insets;
+ if (insets != null)
+ {
+ cellx += insets.left;
+ celly += insets.top;
+ cellw -= insets.left + insets.right;
+ cellh -= insets.top + insets.bottom;
+ }
+
+ // Note: Documentation says that padding is added on both sides, but
+ // visual inspection shows that the Sun implementation only adds it
+ // once, so we do the same.
+ dim.width += constraints.ipadx;
+ dim.height += constraints.ipady;
+
+ switch (constraints.fill)
+ {
+ case GridBagConstraints.HORIZONTAL:
+ dim.width = cellw;
+ break;
+ case GridBagConstraints.VERTICAL:
+ dim.height = cellh;
+ break;
+ case GridBagConstraints.BOTH:
+ dim.width = cellw;
+ dim.height = cellh;
+ break;
+ }
+
+ int x = 0;
+ int y = 0;
+
+ switch (constraints.anchor)
+ {
+ case GridBagConstraints.NORTH:
+ x = cellx + (cellw - dim.width) / 2;
+ y = celly;
+ break;
+ case GridBagConstraints.SOUTH:
+ x = cellx + (cellw - dim.width) / 2;
+ y = celly + cellh - dim.height;
+ break;
+ case GridBagConstraints.WEST:
+ x = cellx;
+ y = celly + (cellh - dim.height) / 2;
+ break;
+ case GridBagConstraints.EAST:
+ x = cellx + cellw - dim.width;
+ y = celly + (cellh - dim.height) / 2;
+ break;
+ case GridBagConstraints.NORTHEAST:
+ x = cellx + cellw - dim.width;
+ y = celly;
+ break;
+ case GridBagConstraints.NORTHWEST:
+ x = cellx;
+ y = celly;
+ break;
+ case GridBagConstraints.SOUTHEAST:
+ x = cellx + cellw - dim.width;
+ y = celly + cellh - dim.height;
+ break;
+ case GridBagConstraints.SOUTHWEST:
+ x = cellx;
+ y = celly + cellh - dim.height;
+ break;
+ default:
+ x = cellx + (cellw - dim.width) / 2;
+ y = celly + (cellh - dim.height) / 2;
+ break;
+ }
+ component.setBounds(info.pos_x + x, info.pos_y + y, dim.width,
+ dim.height);
+ lastComp = component;
+ }
+
+ // DEBUG
+ //dumpLayoutInfo(info);
+
+ // Cache layout information.
+ layoutInfo = getLayoutInfo(parent, PREFERREDSIZE);
+ }
/**
* Obsolete.
signature.asc
Description: This is a digitally signed message part
