This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[gui] [PATCH] Fixes to GridBagLayout.GetLayoutInfo()
- From: David Jee <djee at redhat dot com>
- To: java-patches at gcc dot gnu dot org
- Date: Wed, 16 Jun 2004 16:57:07 -0400
- Subject: [gui] [PATCH] Fixes to GridBagLayout.GetLayoutInfo()
Hello.
I committed the following patch to the java-gui-branch. It fixes a
couple things in GridBagLayout's GetLayoutInfo() method.
-David Jee
2004-06-16 David Jee <djee@redhat.com>
* java/awt/GridBagLayout.java
(GetLayoutInfo): Adjust cell sizes iff parent size is not zero.
Make sure pos_x and pos_y are never negative.
Index: java/awt/GridBagLayout.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/GridBagLayout.java,v
retrieving revision 1.8.2.2
diff -u -r1.8.2.2 GridBagLayout.java
--- java/awt/GridBagLayout.java 16 Feb 2004 17:41:48 -0000 1.8.2.2
+++ java/awt/GridBagLayout.java 16 Jun 2004 20:40:38 -0000
@@ -790,13 +790,26 @@
info.rowWeights);
} // end of STEP 4
- calcCellSizes (info.colWidths, info.colWeights, parentDim.width);
- calcCellSizes (info.rowHeights, info.rowWeights, parentDim.height);
+ // Adjust cell sizes iff parent size not zero.
+ if (parentDim.width > 0 && parentDim.height > 0)
+ {
+ calcCellSizes (info.colWidths, info.colWeights, parentDim.width);
+ calcCellSizes (info.rowHeights, info.rowWeights, parentDim.height);
+ }
int totalWidth = sumIntArray(info.colWidths);
int totalHeight = sumIntArray(info.rowHeights);
- info.pos_x = parentInsets.left + (parentDim.width - totalWidth) / 2;
- info.pos_y = parentInsets.top + (parentDim.height - totalHeight) / 2;
+
+ // Make sure pos_x and pos_y are never negative.
+ if (totalWidth >= parentDim.width)
+ info.pos_x = parentInsets.left;
+ else
+ info.pos_x = parentInsets.left + (parentDim.width - totalWidth) / 2;
+
+ if (totalHeight >= parentDim.height)
+ info.pos_y = parentInsets.top;
+ else
+ info.pos_y = parentInsets.top + (parentDim.height - totalHeight) / 2;
// DEBUG
//dumpLayoutInfo (info);