aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/awt/CardLayout.java
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2002-11-10 23:11:21 +0000
committerTom Tromey <tromey@gcc.gnu.org>2002-11-10 23:11:21 +0000
commit924af605fe5f1e5cfac29d369c3fa50b7bd603dd (patch)
treed386206ae8dd27800faed535df9f14d9a0aecaee /libjava/java/awt/CardLayout.java
parenta6b5bd3b6bae362a975ac28a00c0b9fe01c3ebf8 (diff)
downloadgcc-924af605fe5f1e5cfac29d369c3fa50b7bd603dd.zip
gcc-924af605fe5f1e5cfac29d369c3fa50b7bd603dd.tar.gz
gcc-924af605fe5f1e5cfac29d369c3fa50b7bd603dd.tar.bz2
GridLayout.java (layoutContainer): Use tree lock.
* java/awt/GridLayout.java (layoutContainer): Use tree lock. (getSize): Likewise. * java/awt/FlowLayout.java (layoutContainer): Use tree lock. (getSize): Likewise. * java/awt/BorderLayout.java (layoutContainer): Use tree lock. (calcSize): Likewise. * java/awt/CardLayout.java (getSize): Use tree lock. (gotoComponent): Likewise. (layoutContainer): Likewise. From-SVN: r58998
Diffstat (limited to 'libjava/java/awt/CardLayout.java')
-rw-r--r--libjava/java/awt/CardLayout.java163
1 files changed, 86 insertions, 77 deletions
diff --git a/libjava/java/awt/CardLayout.java b/libjava/java/awt/CardLayout.java
index 38eb91e..10ffa2e 100644
--- a/libjava/java/awt/CardLayout.java
+++ b/libjava/java/awt/CardLayout.java
@@ -165,21 +165,24 @@ public class CardLayout implements LayoutManager2, Serializable
*/
public void layoutContainer (Container parent)
{
- int width = parent.width;
- int height = parent.height;
+ synchronized (parent.getTreeLock ())
+ {
+ int width = parent.width;
+ int height = parent.height;
- Insets ins = parent.getInsets ();
+ Insets ins = parent.getInsets ();
- int num = parent.ncomponents;
- Component[] comps = parent.component;
+ int num = parent.ncomponents;
+ Component[] comps = parent.component;
- int x = ins.left + hgap;
- int y = ins.top + vgap;
- width = width - 2 * hgap - ins.left - ins.right;
- height = height - 2 * vgap - ins.top - ins.bottom;
+ int x = ins.left + hgap;
+ int y = ins.top + vgap;
+ width = width - 2 * hgap - ins.left - ins.right;
+ height = height - 2 * vgap - ins.top - ins.bottom;
- for (int i = 0; i < num; ++i)
- comps[i].setBounds (x, y, width, height);
+ for (int i = 0; i < num; ++i)
+ comps[i].setBounds (x, y, width, height);
+ }
}
/** Get the maximum layout size of the container.
@@ -287,91 +290,97 @@ public class CardLayout implements LayoutManager2, Serializable
private void gotoComponent (Container parent, int what,
Component target)
{
- int num = parent.ncomponents;
- // This is more efficient than calling getComponents().
- Component[] comps = parent.component;
- int choice = -1;
-
- if (what == FIRST)
- choice = 0;
- else if (what == LAST)
- choice = num - 1;
- else if (what >= 0)
- choice = what;
-
- for (int i = 0; i < num; ++i)
+ synchronized (parent.getTreeLock ())
{
- // If TARGET is set then we are looking for a specific
- // component.
- if (target != null)
- {
- if (target == comps[i])
- choice = i;
- }
-
- if (comps[i].isVisible ())
+ int num = parent.ncomponents;
+ // This is more efficient than calling getComponents().
+ Component[] comps = parent.component;
+ int choice = -1;
+
+ if (what == FIRST)
+ choice = 0;
+ else if (what == LAST)
+ choice = num - 1;
+ else if (what >= 0)
+ choice = what;
+
+ for (int i = 0; i < num; ++i)
{
- if (what == NEXT)
+ // If TARGET is set then we are looking for a specific
+ // component.
+ if (target != null)
{
- choice = i + 1;
- if (choice == num)
- choice = 0;
+ if (target == comps[i])
+ choice = i;
}
- else if (what == PREV)
- {
- choice = i - 1;
- if (choice < 0)
- choice = num - 1;
- }
- else if (choice == i)
+
+ if (comps[i].isVisible ())
{
- // Do nothing if we're already looking at the right
- // component.
- return;
+ if (what == NEXT)
+ {
+ choice = i + 1;
+ if (choice == num)
+ choice = 0;
+ }
+ else if (what == PREV)
+ {
+ choice = i - 1;
+ if (choice < 0)
+ choice = num - 1;
+ }
+ else if (choice == i)
+ {
+ // Do nothing if we're already looking at the right
+ // component.
+ return;
+ }
+ comps[i].setVisible (false);
+
+ if (choice >= 0)
+ break;
}
- comps[i].setVisible (false);
-
- if (choice >= 0)
- break;
}
- }
- if (choice >= 0 && choice < num)
- comps[choice].setVisible (true);
+ if (choice >= 0 && choice < num)
+ comps[choice].setVisible (true);
+ }
}
// Compute the size according to WHAT.
private Dimension getSize (Container parent, int what)
{
- int w = 0, h = 0, num = parent.ncomponents;
- Component[] comps = parent.component;
-
- for (int i = 0; i < num; ++i)
+ synchronized (parent.getTreeLock ())
{
- Dimension d;
+ int w = 0, h = 0, num = parent.ncomponents;
+ Component[] comps = parent.component;
+
+ for (int i = 0; i < num; ++i)
+ {
+ Dimension d;
- if (what == MIN)
- d = comps[i].getMinimumSize ();
- else if (what == MAX)
- d = comps[i].getMaximumSize ();
- else
- d = comps[i].getPreferredSize ();
+ if (what == MIN)
+ d = comps[i].getMinimumSize ();
+ else if (what == MAX)
+ d = comps[i].getMaximumSize ();
+ else
+ d = comps[i].getPreferredSize ();
- w = Math.max (d.width, w);
- h = Math.max (d.height, h);
- }
+ w = Math.max (d.width, w);
+ h = Math.max (d.height, h);
+ }
- Insets i = parent.getInsets ();
- w += 2 * hgap + i.right + i.left;
- h += 2 * vgap + i.bottom + i.top;
+ Insets i = parent.getInsets ();
+ w += 2 * hgap + i.right + i.left;
+ h += 2 * vgap + i.bottom + i.top;
- // Handle overflow.
- if (w < 0)
- w = Integer.MAX_VALUE;
- if (h < 0)
- h = Integer.MAX_VALUE;
+ // Handle overflow.
+ if (w < 0)
+ w = Integer.MAX_VALUE;
+ if (h < 0)
+ h = Integer.MAX_VALUE;
- return new Dimension (w, h);
+ return new Dimension (w, h);
+ }
}
/**