summaryrefslogtreecommitdiff
path: root/libjava
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2001-12-19 19:38:25 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2001-12-19 19:38:25 +0000
commit4a796c187c67f4493fb1680246c8c73405e39a8b (patch)
tree35bcde5ff122f6496551a769cae5c3b7763f0856 /libjava
parente3374f8221f04be636fd55e3caefd996da388f9d (diff)
downloadgcc-4a796c187c67f4493fb1680246c8c73405e39a8b.tar.gz
* java/awt/FlowLayout.java (FlowLayout(), FlowLayout(int)): Set
gaps to 5. (FlowLayout(int,int,int)): Use methods to set fields. (getSize): Skip invisible components. (layoutContainer): Skip invisible components. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@48182 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava')
-rw-r--r--libjava/ChangeLog8
-rw-r--r--libjava/java/awt/FlowLayout.java60
2 files changed, 42 insertions, 26 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index cf601a26a9a..3513b273f6e 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,11 @@
+2001-12-19 Tom Tromey <tromey@redhat.com>
+
+ * java/awt/FlowLayout.java (FlowLayout(), FlowLayout(int)): Set
+ gaps to 5.
+ (FlowLayout(int,int,int)): Use methods to set fields.
+ (getSize): Skip invisible components.
+ (layoutContainer): Skip invisible components.
+
2001-12-19 Bryce McKinlay <bryce@waitaki.otago.ac.nz>
* include/jvm.h (_Jv_BuildGCDescr): Declare unconditionally.
diff --git a/libjava/java/awt/FlowLayout.java b/libjava/java/awt/FlowLayout.java
index 95cb6e65521..d33059bf252 100644
--- a/libjava/java/awt/FlowLayout.java
+++ b/libjava/java/awt/FlowLayout.java
@@ -1,6 +1,6 @@
-// GridLayout.java - Grid-based layout engine
+// FlowLayout.java - Grid-based layout engine
-/* Copyright (C) 2000 Free Software Foundation
+/* Copyright (C) 2000, 2001 Free Software Foundation
This file is part of libgcj.
@@ -61,20 +61,20 @@ public class FlowLayout implements LayoutManager, Serializable
}
/** Create a new FlowLayout with center alignment.
- * Both gaps are set to 0.
+ * Both gaps are set to 5.
*/
public FlowLayout ()
{
- this (CENTER, 0, 0);
+ this (CENTER, 5, 5);
}
/** Create a new FlowLayout with the alignment.
- * columns. Both gaps are set to 0.
+ * columns. Both gaps are set to 5.
* @param align Alignment
*/
public FlowLayout (int align)
{
- this (align, 0, 0);
+ this (align, 5, 5);
}
/** Create a new FlowLayout with the specified alignment and gaps.
@@ -85,16 +85,11 @@ public class FlowLayout implements LayoutManager, Serializable
*/
public FlowLayout (int align, int hgap, int vgap)
{
- if (hgap < 0)
- throw new IllegalArgumentException ("horizontal gap must be nonnegative");
- if (vgap < 0)
- throw new IllegalArgumentException ("vertical gap must be nonnegative");
- if (align != LEFT && align != RIGHT && align != CENTER
- && align != LEADING && align != TRAILING)
- throw new IllegalArgumentException ("invalid align: " + align);
- this.align = align;
- this.hgap = hgap;
- this.vgap = vgap;
+ // Use methods to set fields so that we can have all the checking
+ // in one place.
+ setVgap (vgap);
+ setHgap (hgap);
+ setAlignment (align);
}
/** Lay out the container's components based on current settings.
@@ -120,22 +115,29 @@ public class FlowLayout implements LayoutManager, Serializable
int new_w = ins.left + hgap + ins.right;
int new_h = 0;
int j;
- for (j = i; j < num; ++j)
+ boolean found_one = false;
+ for (j = i; j < num && ! found_one; ++j)
{
// FIXME: this is very inefficient.
Dimension c = comps[i].getPreferredSize ();
+
+ // Skip invisible items.
+ if (! comps[i].visible)
+ continue;
+
int next_w = new_w + hgap + c.width;
- if (next_w > d.width)
+ if (next_w <= d.width || ! found_one)
+ {
+ new_w = next_w;
+ new_h = Math.max (new_h, c.height);
+ found_one = true;
+ }
+ else
{
- // We must start a new row.
+ // Must start a new row, and we already found an item
break;
}
- new_w = next_w;
- new_h = Math.max (new_h, c.height);
}
- // We always need at least one item.
- if (j == i)
- ++j;
// Set the location of each component for this row.
int x;
@@ -157,8 +159,11 @@ public class FlowLayout implements LayoutManager, Serializable
{
// FIXME: this is very inefficient.
Dimension c = comps[i].getPreferredSize ();
- comps[i].setLocation (x, y);
- x += c.width + vgap;
+ if (comps[i].visible)
+ {
+ comps[i].setLocation (x, y);
+ x += c.width + vgap;
+ }
}
// Advance to next row.
@@ -241,6 +246,9 @@ public class FlowLayout implements LayoutManager, Serializable
h = 0;
for (int i = 0; i < num; ++i)
{
+ if (! comps[i].visible)
+ continue;
+
// FIXME: can we just directly read the fields in Component?
// Or will that not work with subclassing?
Dimension d;