2000-12-03 14:34:54 +08:00
|
|
|
// CardLayout.java - Card-based layout engine
|
|
|
|
|
2002-01-16 13:32:51 +08:00
|
|
|
/* Copyright (C) 1999, 2000, 2002 Free Software Foundation
|
2000-12-03 14:34:54 +08:00
|
|
|
|
2002-01-16 13:32:51 +08:00
|
|
|
This file is part of GNU Classpath.
|
|
|
|
|
|
|
|
GNU Classpath is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
GNU Classpath is distributed in the hope that it will be useful, but
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with GNU Classpath; see the file COPYING. If not, write to the
|
|
|
|
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
|
|
02111-1307 USA.
|
|
|
|
|
|
|
|
As a special exception, if you link this library with other files to
|
|
|
|
produce an executable, this library does not by itself cause the
|
|
|
|
resulting executable to be covered by the GNU General Public License.
|
|
|
|
This exception does not however invalidate any other reasons why the
|
|
|
|
executable file might be covered by the GNU General Public License. */
|
2000-12-03 14:34:54 +08:00
|
|
|
|
|
|
|
|
|
|
|
package java.awt;
|
|
|
|
|
|
|
|
import java.util.Enumeration;
|
|
|
|
import java.util.Hashtable;
|
|
|
|
import java.io.Serializable;
|
|
|
|
|
|
|
|
/** This class implements a card-based layout scheme. Each included
|
|
|
|
* component is treated as a card. Only one card can be shown at a
|
|
|
|
* time. This class includes methods for changing which card is
|
|
|
|
* shown.
|
|
|
|
*
|
|
|
|
* @author Tom Tromey <tromey@redhat.com>
|
2002-01-16 13:32:51 +08:00
|
|
|
* @author Aaron M. Renn (arenn@urbanophile.com)
|
2000-12-03 14:34:54 +08:00
|
|
|
*/
|
|
|
|
public class CardLayout implements LayoutManager2, Serializable
|
|
|
|
{
|
2002-01-16 13:32:51 +08:00
|
|
|
/**
|
|
|
|
* Initializes a new instance of <code>CardLayout</code> with horizontal
|
|
|
|
* and vertical gaps of 0.
|
|
|
|
*/
|
2000-12-03 14:34:54 +08:00
|
|
|
public CardLayout ()
|
|
|
|
{
|
|
|
|
this (0, 0);
|
|
|
|
}
|
|
|
|
|
2002-01-16 13:32:51 +08:00
|
|
|
/**
|
|
|
|
* Create a new <code>CardLayout</code> object with the specified
|
|
|
|
* horizontal and vertical gaps.
|
2000-12-03 14:34:54 +08:00
|
|
|
* @param hgap The horizontal gap
|
|
|
|
* @param vgap The vertical gap
|
|
|
|
*/
|
|
|
|
public CardLayout (int hgap, int vgap)
|
|
|
|
{
|
|
|
|
this.hgap = hgap;
|
|
|
|
this.vgap = vgap;
|
2002-01-16 13:32:51 +08:00
|
|
|
this.tab = new Hashtable ();
|
2000-12-03 14:34:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Add a new component to the layout. The constraint must be a
|
|
|
|
* string which is used to name the component. This string can
|
|
|
|
* later be used to refer to the particular component.
|
|
|
|
* @param comp The component to add
|
|
|
|
* @param constraints The name by which the component can later be called
|
2002-01-16 13:32:51 +08:00
|
|
|
* @exception IllegalArgumentException If `constraints' is not a
|
|
|
|
* <code>String</code>
|
2000-12-03 14:34:54 +08:00
|
|
|
*/
|
|
|
|
public void addLayoutComponent (Component comp, Object constraints)
|
|
|
|
{
|
|
|
|
if (! (constraints instanceof String))
|
|
|
|
throw new IllegalArgumentException ("Object " + constraints
|
|
|
|
+ " is not a string");
|
2002-01-16 13:32:51 +08:00
|
|
|
tab.put (constraints, comp);
|
2000-12-03 14:34:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Add a new component to the layout. The name can be used later
|
|
|
|
* to refer to the component.
|
|
|
|
* @param name The name by which the component can later be called
|
|
|
|
* @param comp The component to add
|
2002-01-16 13:32:51 +08:00
|
|
|
* @deprecated This method is deprecated in favor of
|
|
|
|
* <code>addLayoutComponent(Component, Object)</code>.
|
2000-12-03 14:34:54 +08:00
|
|
|
*/
|
|
|
|
public void addLayoutComponent (String name, Component comp)
|
|
|
|
{
|
|
|
|
addLayoutComponent (comp, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Cause the first component in the container to be displayed.
|
|
|
|
* @param parent The parent container
|
|
|
|
*/
|
|
|
|
public void first (Container parent)
|
|
|
|
{
|
|
|
|
gotoComponent (parent, FIRST, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Return this layout manager's horizontal gap. */
|
|
|
|
public int getHgap ()
|
|
|
|
{
|
|
|
|
return hgap;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Return this layout manager's x alignment. This method always
|
|
|
|
* returns Component.CENTER_ALIGNMENT.
|
|
|
|
* @param parent Container using this layout manager instance
|
|
|
|
*/
|
|
|
|
public float getLayoutAlignmentX (Container parent)
|
|
|
|
{
|
|
|
|
return Component.CENTER_ALIGNMENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Returns this layout manager's y alignment. This method always
|
|
|
|
* returns Component.CENTER_ALIGNMENT.
|
|
|
|
* @param parent Container using this layout manager instance
|
|
|
|
*/
|
|
|
|
public float getLayoutAlignmentY (Container parent)
|
|
|
|
{
|
|
|
|
return Component.CENTER_ALIGNMENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Return this layout manager's vertical gap. */
|
|
|
|
public int getVgap ()
|
|
|
|
{
|
|
|
|
return vgap;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Invalidate this layout manager's state. */
|
|
|
|
public void invalidateLayout (Container target)
|
|
|
|
{
|
|
|
|
// Do nothing.
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Cause the last component in the container to be displayed.
|
|
|
|
* @param parent The parent container
|
|
|
|
*/
|
|
|
|
public void last (Container parent)
|
|
|
|
{
|
|
|
|
gotoComponent (parent, LAST, null);
|
|
|
|
}
|
|
|
|
|
2002-01-16 13:32:51 +08:00
|
|
|
/**
|
|
|
|
* Lays out the container. This is done by resizing the child components
|
|
|
|
* to be the same size as the parent, less insets and gaps.
|
|
|
|
*
|
|
|
|
* @param parent The parent container.
|
|
|
|
*/
|
2000-12-03 14:34:54 +08:00
|
|
|
public void layoutContainer (Container parent)
|
|
|
|
{
|
2000-12-26 08:25:13 +08:00
|
|
|
int width = parent.width;
|
|
|
|
int height = parent.height;
|
2000-12-03 14:34:54 +08:00
|
|
|
|
|
|
|
Insets ins = parent.getInsets ();
|
|
|
|
|
2000-12-26 08:25:13 +08:00
|
|
|
int num = parent.ncomponents;
|
2000-12-03 14:34:54 +08:00
|
|
|
Component[] comps = parent.component;
|
2000-12-26 08:25:13 +08:00
|
|
|
|
2002-01-16 13:32:51 +08:00
|
|
|
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;
|
|
|
|
|
2000-12-03 14:34:54 +08:00
|
|
|
for (int i = 0; i < num; ++i)
|
2002-01-16 13:32:51 +08:00
|
|
|
comps[i].setBounds (x, y, width, height);
|
2000-12-03 14:34:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Get the maximum layout size of the container.
|
|
|
|
* @param target The parent container
|
|
|
|
*/
|
|
|
|
public Dimension maximumLayoutSize (Container target)
|
|
|
|
{
|
|
|
|
// The JCL says that this returns Integer.MAX_VALUE for both
|
|
|
|
// dimensions. But that just seems wrong to me.
|
|
|
|
return getSize (target, MAX);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Get the minimum layout size of the container.
|
|
|
|
* @param target The parent container
|
|
|
|
*/
|
|
|
|
public Dimension minimumLayoutSize (Container target)
|
|
|
|
{
|
|
|
|
return getSize (target, MIN);
|
|
|
|
}
|
|
|
|
|
2002-01-16 13:32:51 +08:00
|
|
|
/** Cause the next component in the container to be displayed. If
|
|
|
|
* this current card is the last one in the deck, the first
|
|
|
|
* component is displayed.
|
2000-12-03 14:34:54 +08:00
|
|
|
* @param parent The parent container
|
|
|
|
*/
|
|
|
|
public void next (Container parent)
|
|
|
|
{
|
|
|
|
gotoComponent (parent, NEXT, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Get the preferred layout size of the container.
|
|
|
|
* @param target The parent container
|
|
|
|
*/
|
|
|
|
public Dimension preferredLayoutSize (Container parent)
|
|
|
|
{
|
|
|
|
return getSize (parent, PREF);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Cause the previous component in the container to be displayed.
|
2002-01-16 13:32:51 +08:00
|
|
|
* If this current card is the first one in the deck, the last
|
|
|
|
* component is displayed.
|
2000-12-03 14:34:54 +08:00
|
|
|
* @param parent The parent container
|
|
|
|
*/
|
|
|
|
public void previous (Container parent)
|
|
|
|
{
|
|
|
|
gotoComponent (parent, PREV, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Remove the indicated component from this layout manager.
|
|
|
|
* @param comp The component to remove
|
|
|
|
*/
|
|
|
|
public void removeLayoutComponent (Component comp)
|
|
|
|
{
|
2002-01-16 13:32:51 +08:00
|
|
|
Enumeration e = tab.keys ();
|
2000-12-03 14:34:54 +08:00
|
|
|
while (e.hasMoreElements ())
|
|
|
|
{
|
|
|
|
Object key = e.nextElement ();
|
2002-01-16 13:32:51 +08:00
|
|
|
if (tab.get (key) == comp)
|
2000-12-03 14:34:54 +08:00
|
|
|
{
|
2002-01-16 13:32:51 +08:00
|
|
|
tab.remove (key);
|
2000-12-03 14:34:54 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Set this layout manager's horizontal gap.
|
|
|
|
* @param hgap The new gap
|
|
|
|
*/
|
|
|
|
public void setHgap (int hgap)
|
|
|
|
{
|
|
|
|
this.hgap = hgap;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Set this layout manager's vertical gap.
|
|
|
|
* @param vgap The new gap
|
|
|
|
*/
|
|
|
|
public void setVgap (int vgap)
|
|
|
|
{
|
|
|
|
this.vgap = vgap;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Cause the named component to be shown. If the component name is
|
|
|
|
* unknown, this method does nothing.
|
|
|
|
* @param parent The parent container
|
|
|
|
* @param name The name of the component to show
|
|
|
|
*/
|
|
|
|
public void show (Container parent, String name)
|
|
|
|
{
|
2002-01-16 13:32:51 +08:00
|
|
|
Object target = tab.get (name);
|
2000-12-03 14:34:54 +08:00
|
|
|
if (target != null)
|
|
|
|
gotoComponent (parent, NONE, (Component) target);
|
|
|
|
}
|
|
|
|
|
2002-01-16 13:32:51 +08:00
|
|
|
/**
|
|
|
|
* Returns a string representation of this layout manager.
|
|
|
|
*
|
|
|
|
* @return A string representation of this object.
|
|
|
|
*/
|
2000-12-03 14:34:54 +08:00
|
|
|
public String toString ()
|
|
|
|
{
|
|
|
|
return getClass ().getName () + "[" + hgap + "," + vgap + "]";
|
|
|
|
}
|
|
|
|
|
|
|
|
// This implements first(), last(), next(), and previous().
|
|
|
|
private void gotoComponent (Container parent, int what,
|
|
|
|
Component target)
|
|
|
|
{
|
2002-01-16 13:32:51 +08:00
|
|
|
int num = parent.ncomponents;
|
2000-12-03 14:34:54 +08:00
|
|
|
// This is more efficient than calling getComponents().
|
|
|
|
Component[] comps = parent.component;
|
|
|
|
int choice = -1;
|
|
|
|
|
|
|
|
if (what == FIRST)
|
|
|
|
choice = 0;
|
|
|
|
else if (what == LAST)
|
2002-01-16 13:32:51 +08:00
|
|
|
choice = num - 1;
|
2000-12-03 14:34:54 +08:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
choice = i + 1;
|
|
|
|
if (choice == num)
|
Start of AWT merge with Classpath:
* Makefile.in: Rebuilt.
* Makefile.am (awt_java_source_files): Reference files in
gnu/java/awt, not gnu/gcj/awt.
* java/awt/image/BufferedImage.java: Updated copyright.
* java/awt/image/ComponentColorModel.java: Updated copyright.
* java/awt/image/ComponentSampleModel.java: Updated copyright.
* java/awt/image/DataBuffer.java: Updated copyright.
* java/awt/image/DataBufferByte.java: Updated copyright.
* java/awt/image/DataBufferInt.java: Updated copyright.
* java/awt/image/DataBufferUShort.java: Updated copyright.
* java/awt/image/IndexColorModel.java: Updated copyright.
* java/awt/image/PackedColorModel.java: Updated copyright.
* java/awt/image/Raster.java: Updated copyright.
* java/awt/image/RasterOp.java: Updated copyright.
* java/awt/image/SampleModel.java: Updated copyright.
* java/awt/image/SinglePixelPackedSampleModel.java: Updated copyright.
* java/awt/image/WritableRaster.java: Updated copyright.
* java/awt/color/ColorSpace.java: Updated copyright.
* java/awt/color/ICC_ColorSpace.java: Updated copyright
* java/awt/color/ICC_Profile.java: Updated copyright.
* java/awt/event/HierarchyBoundsAdapter.java: Updated copyright.
* java/awt/event/HierarchyBoundsListener.java: Updated copyright.
* java/awt/event/HierarchyEvent.java: Updated copyright.
* java/awt/event/HierarchyListener.java: Updated copyright.
* java/awt/geom/AffineTransform.java: Updated copyright.
* java/awt/geom/Dimension2D.java: Updated copyright.
* java/awt/geom/Ellipse2D.java: Updated copyright.
* java/awt/geom/IllegalPathStateException.java: Updated copyright.
* java/awt/geom/Line2D.java: Updated copyright.
* java/awt/geom/NoninvertibleTransformException.java: Updated
copyright.
* java/awt/geom/PathIterator.java: Updated copyright.
* java/awt/geom/Point2D.java: Updated copyright.
* java/awt/geom/Rectangle2D.java: Updated copyright.
* java/awt/geom/RectangularShape.java: Updated copyright.
* java/awt/geom/RoundRectangle2D.java: Updated copyright.
* java/awt/Toolkit.java: Updated import for file moves.
* java/awt/Rectangle.java: Updated copyright; added javadoc from
Classpath.
(hashCode): New method from Classpath.
* java/awt/Graphics2D.java: Updated copyright.
* java/awt/Transparency.java: Updated copyright.
* java/awt/Paint.java: Updated copyright.
* java/awt/Graphics.java: New version from Classpath.
* java/awt/EventDispatchThread.java: Updated copyright.
* java/awt/CardLayout.java (layoutContainer): Don't skip invisible
children.
(gotoComponent): Wrap around on next/previous.
* gnu/gcj/awt/BitMaskExtent.java: Removed.
* gnu/gcj/awt/Buffers.java: Removed.
* gnu/gcj/awt/ComponentDataBlitOp.java: Removed.
* gnu/gcj/awt/GLightweightPeer.java: Removed.
* gnu/java/awt/BitMaskExtent.java: Added.
* gnu/java/awt/Buffers.java: Added.
* gnu/java/awt/ComponentDataBlitOp.java: Added.
* gnu/java/awt/GLightweightPeer.java: Added.
* java/awt/geom/Line2D.java (clone): Ignore
CloneNotSupportedException.
* gnu/gcj/awt/GLightweightPeer.java (getColorModel): New method.
* java/awt/Frame.java: Merged with Classpath.
* java/awt/RenderingHints.java: Copyright update.
* java/awt/Paint.java: Copyright update.
* java/awt/image/DirectColorModel.java: Merged with Classpath.
* java/awt/image/ColorModel.java: Merged with Classpath.
* java/awt/Window.java (show): New Implementation from Classpath.
(isShowing): Use super.isShowing().
* java/awt/EventQueue.java: Merged with Classpath.
* java/awt/AWTEventMulticaster.java (save): Throw
RuntimeException.
(saveInternal): Likewise.
* java/awt/AWTEvent.java: Now implements Serializable.
* java/awt/Event.java: Copyright update.
* java/awt/peer/ComponentPeer.java: Merged with Classpath.
* java/awt/image/BufferedImage.java: Copyright update.
* java/awt/GraphicsConfiguration.java: Copyright update.
* java/awt/Component.java: (addNotify): Don't call
addNotifyContainerChildren().
(addNotifyContainerChildren): Removed.
(setPeer): New method from Classpath.
(setTreeLock): Likewise.
(setVisible): Rewrote.
(show): Use it.
(hide): Likewise.
(validate): Set `valid'.
(checkImage(Image,ImageObserver)): Implementation from Classpath.
(createImage(ImageProducer)): Likewise.
(prepareImage): Likewise.
* java/awt/Container.java (addImpl): Handle case where constraint
is not a String. Post event via system event queue.
(remove): Post event via system event queue.
(validateTree): Only validate child if it is invalid.
(getAlignmentX): Call super method as default.
(getAlignmentY): Likewise.
(addContainerListener): Now synchronized.
(removeContainerListener): Likewise.
(addNotifyContainerChildren): Now private.
* java/awt/ComponentOrientation.java: Updated copyright. Added
@author.
* java/awt/FlowLayout.java (serialVersionUID): New field.
(setAlignment): Better exception message.
(layoutContainer): Don't compute component's preferred size unless
we're going to use it.
* java/awt/BorderLayout.java (AFTER_LAST_LINE, AFTER_LINE_ENDS,
BEFORE_FIRST_LINE, BEFORE_LINE_BEGINS): New constants.
(firstLine, lastLine, firstItem, lastItem): New fields.
(addLayoutComponent): Handle case where constraints is null.
Also, handle relative locations.
(removeLayoutComponent): Handle relative locations.
(MIN, MAX, PREF): New constants.
(calcCompSize): New method.
(calcSize): New method.
(minimumLayoutSize): Use it.
(preferredLayoutSize): Likewise.
(maximumLayoutSize): Likewise.
(toString): Include more information.
(setBounds): New method.
(layoutContainer): Use libgcj implementation; extended to handle
relative locations.
From-SVN: r48896
2002-01-16 12:21:35 +08:00
|
|
|
choice = 0;
|
2000-12-03 14:34:54 +08:00
|
|
|
}
|
|
|
|
else if (what == PREV)
|
|
|
|
{
|
|
|
|
choice = i - 1;
|
|
|
|
if (choice < 0)
|
Start of AWT merge with Classpath:
* Makefile.in: Rebuilt.
* Makefile.am (awt_java_source_files): Reference files in
gnu/java/awt, not gnu/gcj/awt.
* java/awt/image/BufferedImage.java: Updated copyright.
* java/awt/image/ComponentColorModel.java: Updated copyright.
* java/awt/image/ComponentSampleModel.java: Updated copyright.
* java/awt/image/DataBuffer.java: Updated copyright.
* java/awt/image/DataBufferByte.java: Updated copyright.
* java/awt/image/DataBufferInt.java: Updated copyright.
* java/awt/image/DataBufferUShort.java: Updated copyright.
* java/awt/image/IndexColorModel.java: Updated copyright.
* java/awt/image/PackedColorModel.java: Updated copyright.
* java/awt/image/Raster.java: Updated copyright.
* java/awt/image/RasterOp.java: Updated copyright.
* java/awt/image/SampleModel.java: Updated copyright.
* java/awt/image/SinglePixelPackedSampleModel.java: Updated copyright.
* java/awt/image/WritableRaster.java: Updated copyright.
* java/awt/color/ColorSpace.java: Updated copyright.
* java/awt/color/ICC_ColorSpace.java: Updated copyright
* java/awt/color/ICC_Profile.java: Updated copyright.
* java/awt/event/HierarchyBoundsAdapter.java: Updated copyright.
* java/awt/event/HierarchyBoundsListener.java: Updated copyright.
* java/awt/event/HierarchyEvent.java: Updated copyright.
* java/awt/event/HierarchyListener.java: Updated copyright.
* java/awt/geom/AffineTransform.java: Updated copyright.
* java/awt/geom/Dimension2D.java: Updated copyright.
* java/awt/geom/Ellipse2D.java: Updated copyright.
* java/awt/geom/IllegalPathStateException.java: Updated copyright.
* java/awt/geom/Line2D.java: Updated copyright.
* java/awt/geom/NoninvertibleTransformException.java: Updated
copyright.
* java/awt/geom/PathIterator.java: Updated copyright.
* java/awt/geom/Point2D.java: Updated copyright.
* java/awt/geom/Rectangle2D.java: Updated copyright.
* java/awt/geom/RectangularShape.java: Updated copyright.
* java/awt/geom/RoundRectangle2D.java: Updated copyright.
* java/awt/Toolkit.java: Updated import for file moves.
* java/awt/Rectangle.java: Updated copyright; added javadoc from
Classpath.
(hashCode): New method from Classpath.
* java/awt/Graphics2D.java: Updated copyright.
* java/awt/Transparency.java: Updated copyright.
* java/awt/Paint.java: Updated copyright.
* java/awt/Graphics.java: New version from Classpath.
* java/awt/EventDispatchThread.java: Updated copyright.
* java/awt/CardLayout.java (layoutContainer): Don't skip invisible
children.
(gotoComponent): Wrap around on next/previous.
* gnu/gcj/awt/BitMaskExtent.java: Removed.
* gnu/gcj/awt/Buffers.java: Removed.
* gnu/gcj/awt/ComponentDataBlitOp.java: Removed.
* gnu/gcj/awt/GLightweightPeer.java: Removed.
* gnu/java/awt/BitMaskExtent.java: Added.
* gnu/java/awt/Buffers.java: Added.
* gnu/java/awt/ComponentDataBlitOp.java: Added.
* gnu/java/awt/GLightweightPeer.java: Added.
* java/awt/geom/Line2D.java (clone): Ignore
CloneNotSupportedException.
* gnu/gcj/awt/GLightweightPeer.java (getColorModel): New method.
* java/awt/Frame.java: Merged with Classpath.
* java/awt/RenderingHints.java: Copyright update.
* java/awt/Paint.java: Copyright update.
* java/awt/image/DirectColorModel.java: Merged with Classpath.
* java/awt/image/ColorModel.java: Merged with Classpath.
* java/awt/Window.java (show): New Implementation from Classpath.
(isShowing): Use super.isShowing().
* java/awt/EventQueue.java: Merged with Classpath.
* java/awt/AWTEventMulticaster.java (save): Throw
RuntimeException.
(saveInternal): Likewise.
* java/awt/AWTEvent.java: Now implements Serializable.
* java/awt/Event.java: Copyright update.
* java/awt/peer/ComponentPeer.java: Merged with Classpath.
* java/awt/image/BufferedImage.java: Copyright update.
* java/awt/GraphicsConfiguration.java: Copyright update.
* java/awt/Component.java: (addNotify): Don't call
addNotifyContainerChildren().
(addNotifyContainerChildren): Removed.
(setPeer): New method from Classpath.
(setTreeLock): Likewise.
(setVisible): Rewrote.
(show): Use it.
(hide): Likewise.
(validate): Set `valid'.
(checkImage(Image,ImageObserver)): Implementation from Classpath.
(createImage(ImageProducer)): Likewise.
(prepareImage): Likewise.
* java/awt/Container.java (addImpl): Handle case where constraint
is not a String. Post event via system event queue.
(remove): Post event via system event queue.
(validateTree): Only validate child if it is invalid.
(getAlignmentX): Call super method as default.
(getAlignmentY): Likewise.
(addContainerListener): Now synchronized.
(removeContainerListener): Likewise.
(addNotifyContainerChildren): Now private.
* java/awt/ComponentOrientation.java: Updated copyright. Added
@author.
* java/awt/FlowLayout.java (serialVersionUID): New field.
(setAlignment): Better exception message.
(layoutContainer): Don't compute component's preferred size unless
we're going to use it.
* java/awt/BorderLayout.java (AFTER_LAST_LINE, AFTER_LINE_ENDS,
BEFORE_FIRST_LINE, BEFORE_LINE_BEGINS): New constants.
(firstLine, lastLine, firstItem, lastItem): New fields.
(addLayoutComponent): Handle case where constraints is null.
Also, handle relative locations.
(removeLayoutComponent): Handle relative locations.
(MIN, MAX, PREF): New constants.
(calcCompSize): New method.
(calcSize): New method.
(minimumLayoutSize): Use it.
(preferredLayoutSize): Likewise.
(maximumLayoutSize): Likewise.
(toString): Include more information.
(setBounds): New method.
(layoutContainer): Use libgcj implementation; extended to handle
relative locations.
From-SVN: r48896
2002-01-16 12:21:35 +08:00
|
|
|
choice = num - 1;
|
2000-12-03 14:34:54 +08:00
|
|
|
}
|
2002-01-16 13:32:51 +08:00
|
|
|
else if (choice == i)
|
2000-12-03 14:34:54 +08:00
|
|
|
{
|
|
|
|
// Do nothing if we're already looking at the right
|
|
|
|
// component.
|
2002-01-16 13:32:51 +08:00
|
|
|
return;
|
2000-12-03 14:34:54 +08:00
|
|
|
}
|
|
|
|
comps[i].setVisible (false);
|
|
|
|
|
|
|
|
if (choice >= 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-01-16 13:32:51 +08:00
|
|
|
if (choice >= 0 && choice < num)
|
|
|
|
comps[choice].setVisible (true);
|
2000-12-03 14:34:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Compute the size according to WHAT.
|
|
|
|
private Dimension getSize (Container parent, int what)
|
|
|
|
{
|
2000-12-26 08:25:13 +08:00
|
|
|
int w = 0, h = 0, num = parent.ncomponents;
|
2000-12-03 14:34:54 +08:00
|
|
|
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 ();
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
// Handle overflow.
|
|
|
|
if (w < 0)
|
|
|
|
w = Integer.MAX_VALUE;
|
|
|
|
if (h < 0)
|
|
|
|
h = Integer.MAX_VALUE;
|
|
|
|
|
|
|
|
return new Dimension (w, h);
|
|
|
|
}
|
|
|
|
|
2002-01-16 13:32:51 +08:00
|
|
|
/**
|
|
|
|
* @serial Horizontal gap value.
|
|
|
|
*/
|
2000-12-03 14:34:54 +08:00
|
|
|
private int hgap;
|
2002-01-16 13:32:51 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @serial Vertical gap value.
|
|
|
|
*/
|
2000-12-03 14:34:54 +08:00
|
|
|
private int vgap;
|
|
|
|
|
2002-01-16 13:32:51 +08:00
|
|
|
/**
|
|
|
|
* @serial Table of named components.
|
|
|
|
*/
|
|
|
|
private Hashtable tab;
|
2000-12-03 14:34:54 +08:00
|
|
|
|
|
|
|
// These constants are used by the private gotoComponent method.
|
|
|
|
private int FIRST = 0;
|
|
|
|
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;
|
|
|
|
private int MAX = 1;
|
|
|
|
private int PREF = 2;
|
|
|
|
}
|