|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.neu.ccs.gui.AbsoluteLayout
Layout manager allowing child components of a container to control their own locations and sizes.
In version 2.3.5, a serious bug was fixed. In the possess of
fixing the bug, the following policy about the determination of
Component size was implemented.
If a Component is actually a Container
then its size is computed by calling getPreferredSize
and any existing size set by setSize is ignored.
This permits objects that extend Container to
effectively change their size by changing the return value of
getPreferredSize and this change is not affected
by an obsolete value set earlier by setSize.
For a general Component, the size is set to be
the maximum of getSize and getMinimumSize.
This approach was a design choice based on the fact that for
many older Java Component objects people often
directly set the size and do not bother with the minimum size.
This means that the resulting size set in this layout manager
is at least a big as both the actual size set earlier and the
minimum size.
The size policy is consistent with the effort in JPT to use
getPreferredSize (which is algorithmic) rather
than rely on size settings that may become obsolete for
dynamically changing components.
| Field Summary | |
protected Vector |
components
Child components of the parent container. |
| Constructor Summary | |
AbsoluteLayout()
|
|
| Method Summary | |
void |
addLayoutComponent(Component component,
Object constraints)
Adds the given component to this layout with the given constraints. |
void |
addLayoutComponent(String name,
Component component)
Adds the given component to this layout with the given name. |
float |
getLayoutAlignmentX(Container target)
Returns the layout alignment along the x-axis. |
float |
getLayoutAlignmentY(Container target)
Returns the layout alignment along the y-axis. |
static Rectangle |
getPreferredBounds(Component c)
If the component is a container then returns bounds where the width and height are replaced by the width and height of the preferred size. |
void |
invalidateLayout(Container parent)
This method does nothing, as this layout does not cache information about its parent container. |
void |
layoutContainer(Container parent)
Lays out the container. |
Dimension |
maximumLayoutSize(Container parent)
Returns the maximum size required to layout the components contained in the parent container. |
Dimension |
minimumLayoutSize(Container parent)
Returns the minimum size required to layout the components contained in the parent container. |
Dimension |
preferredLayoutSize(Container parent)
Returns the preferred size required to layout the components contained in the parent container. |
void |
removeLayoutComponent(Component component)
Removes the given component from this layout. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected Vector components
| Constructor Detail |
public AbsoluteLayout()
| Method Detail |
public void addLayoutComponent(String name,
Component component)
Adds the given component to this layout with the given name.
Ignores a null component.
Ignores the name parameter.
addLayoutComponent in interface LayoutManagername - the name for the componentcomponent - the component to be addedaddLayoutComponent(Component, Object)
public void addLayoutComponent(Component component,
Object constraints)
Adds the given component to this layout with the given constraints.
Ignores a null component.
Ignores the constraints parameter since the position
is determined by getLocation and the size is
computed by the policy described in the introduction to
the class.
addLayoutComponent in interface LayoutManager2component - the component to be addedconstraints - the constraints applied to the componentaddLayoutComponent(String, Component)public void removeLayoutComponent(Component component)
Removes the given component from this layout.
removeLayoutComponent in interface LayoutManagercomponent - the component to be removedpublic Dimension minimumLayoutSize(Container parent)
Returns the minimum size required to layout the components contained in the parent container. This will be the same as the preferred layout size.
minimumLayoutSize in interface LayoutManagerparent - the parent containerpreferredLayoutSize(Container),
maximumLayoutSize(Container)public Dimension preferredLayoutSize(Container parent)
Returns the preferred size required to layout the components contained in the parent container.
This method computes component size by the policy described in the introduction to the class.
preferredLayoutSize in interface LayoutManagerparent - the parent containerminimumLayoutSize(Container),
maximumLayoutSize(Container)public Dimension maximumLayoutSize(Container parent)
Returns the maximum size required to layout the components contained in the parent container. This will be the same as the preferred layout size.
maximumLayoutSize in interface LayoutManager2parent - the parent containerminimumLayoutSize(Container),
preferredLayoutSize(Container)public void layoutContainer(Container parent)
Lays out the container.
This implementation ensures that components have a size equal to their preferred size if that value is available or at least as big as their minimum size otherwise.
This counteracts a bug (feature?) of Java that some components have an initial size of (0,0) even when their preferred size is not zero.
The location (upper-left) of each component is left as is.
layoutContainer in interface LayoutManagerparent - the parent containerpublic float getLayoutAlignmentY(Container target)
getLayoutAlignmentY in interface LayoutManager2target - the target containergetLayoutAlignmentX(Container)public float getLayoutAlignmentX(Container target)
getLayoutAlignmentX in interface LayoutManager2target - the target containergetLayoutAlignmentY(Container)public void invalidateLayout(Container parent)
invalidateLayout in interface LayoutManager2parent - the parent containerpublic static Rectangle getPreferredBounds(Component c)
If the component is a container then returns bounds where the width and height are replaced by the width and height of the preferred size. The current size is ignored in this case.
Otherwise, returns the maximum of the current size and the minimum size.
The location is set to the value returned by
the method getLocation
This method is used to implement the size policy described in the introduction to the class.
c - the component whose preferred bounds are required
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||