mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-12-03 16:54:27 +08:00
CardLayout.java (show): Rewrote.
2003-01-15 Scott Gilbertson <scottg@mantatest.com> * java/awt/CardLayout.java (show): Rewrote. (gotoComponent): Removed `target' argument. Simplified code. Don't pre-compute `choice' unless `what' is FIRST or LAST. Changed all callers. (NONE): Removed. From-SVN: r61357
This commit is contained in:
parent
3dd5fc583b
commit
09d096a8d7
@ -1,3 +1,11 @@
|
||||
2003-01-15 Scott Gilbertson <scottg@mantatest.com>
|
||||
|
||||
* java/awt/CardLayout.java (show): Rewrote.
|
||||
(gotoComponent): Removed `target' argument. Simplified code.
|
||||
Don't pre-compute `choice' unless `what' is FIRST or LAST.
|
||||
Changed all callers.
|
||||
(NONE): Removed.
|
||||
|
||||
2003-01-14 Michael Koch <konqueror@gmx.de>
|
||||
|
||||
* java/net/InetSocketAddress.java
|
||||
|
@ -1,6 +1,6 @@
|
||||
// CardLayout.java - Card-based layout engine
|
||||
|
||||
/* Copyright (C) 1999, 2000, 2002 Free Software Foundation
|
||||
/* Copyright (C) 1999, 2000, 2002, 2003 Free Software Foundation
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@ -110,7 +110,7 @@ public class CardLayout implements LayoutManager2, Serializable
|
||||
*/
|
||||
public void first (Container parent)
|
||||
{
|
||||
gotoComponent (parent, FIRST, null);
|
||||
gotoComponent (parent, FIRST);
|
||||
}
|
||||
|
||||
/** Return this layout manager's horizontal gap. */
|
||||
@ -154,7 +154,7 @@ public class CardLayout implements LayoutManager2, Serializable
|
||||
*/
|
||||
public void last (Container parent)
|
||||
{
|
||||
gotoComponent (parent, LAST, null);
|
||||
gotoComponent (parent, LAST);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -210,7 +210,7 @@ public class CardLayout implements LayoutManager2, Serializable
|
||||
*/
|
||||
public void next (Container parent)
|
||||
{
|
||||
gotoComponent (parent, NEXT, null);
|
||||
gotoComponent (parent, NEXT);
|
||||
}
|
||||
|
||||
/** Get the preferred layout size of the container.
|
||||
@ -228,7 +228,7 @@ public class CardLayout implements LayoutManager2, Serializable
|
||||
*/
|
||||
public void previous (Container parent)
|
||||
{
|
||||
gotoComponent (parent, PREV, null);
|
||||
gotoComponent (parent, PREV);
|
||||
}
|
||||
|
||||
/** Remove the indicated component from this layout manager.
|
||||
@ -273,7 +273,21 @@ public class CardLayout implements LayoutManager2, Serializable
|
||||
{
|
||||
Object target = tab.get (name);
|
||||
if (target != null)
|
||||
gotoComponent (parent, NONE, (Component) target);
|
||||
{
|
||||
int num = parent.ncomponents;
|
||||
// This is more efficient than calling getComponents().
|
||||
Component[] comps = parent.component;
|
||||
for (int i = 0; i < num; ++i)
|
||||
{
|
||||
if (comps[i].isVisible())
|
||||
{
|
||||
if (target == comps[i])
|
||||
return;
|
||||
comps[i].setVisible (false);
|
||||
}
|
||||
}
|
||||
((Component) target).setVisible (true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -286,9 +300,11 @@ public class CardLayout implements LayoutManager2, Serializable
|
||||
return getClass ().getName () + "[" + hgap + "," + vgap + "]";
|
||||
}
|
||||
|
||||
// This implements first(), last(), next(), and previous().
|
||||
private void gotoComponent (Container parent, int what,
|
||||
Component target)
|
||||
/** This implements first(), last(), next(), and previous().
|
||||
* @param parent The parent container
|
||||
* @param what The type of goto: FIRST, LAST, NEXT or PREV
|
||||
*/
|
||||
private void gotoComponent (Container parent, int what)
|
||||
{
|
||||
synchronized (parent.getTreeLock ())
|
||||
{
|
||||
@ -301,19 +317,9 @@ public class CardLayout implements LayoutManager2, Serializable
|
||||
choice = 0;
|
||||
else if (what == LAST)
|
||||
choice = num - 1;
|
||||
else if (what >= 0)
|
||||
choice = what;
|
||||
|
||||
for (int i = 0; i < num; ++i)
|
||||
{
|
||||
// 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 ())
|
||||
{
|
||||
if (what == NEXT)
|
||||
@ -335,7 +341,7 @@ public class CardLayout implements LayoutManager2, Serializable
|
||||
return;
|
||||
}
|
||||
comps[i].setVisible (false);
|
||||
|
||||
|
||||
if (choice >= 0)
|
||||
break;
|
||||
}
|
||||
@ -403,7 +409,6 @@ public class CardLayout implements LayoutManager2, Serializable
|
||||
private int LAST = 1;
|
||||
private int NEXT = 2;
|
||||
private int PREV = 3;
|
||||
private int NONE = 4;
|
||||
|
||||
// These constants are used by the private getSize method.
|
||||
private int MIN = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user