All Packages  This Package  Class Hierarchy  Class Search  Index

Class matthew.awt.StrutLayout
java.lang.Object
   |
   +----matthew.awt.StrutLayout

  Summary

public class  StrutLayout
     extends java.lang.Object
     implements java.awt.LayoutManager2
{
          // Fields 25
     public static final int BOTTOM_LEFT;
     public static final int BOTTOM_RIGHT;
     public static final int CENTER;
     public static final int EAST;
     public static final int MID_BOTTOM;
     public static final int MID_LEFT;
     public static final int MID_RIGHT;
     public static final int MID_TOP;
     public static final int NORTH;
     public static final int NORTH_EAST;
     public static final int NORTH_WEST;
     public static final int SIZE_BOTH;
     public static final int SIZE_HEIGHT;
     public static final int SIZE_NONE;
     public static final int SIZE_WIDTH;
     public static final int SOUTH;
     public static final int SOUTH_EAST;
     public static final int SOUTH_WEST;
     public static final int SPRING_BOTH;
     public static final int SPRING_HORIZ;
     public static final int SPRING_NONE;
     public static final int SPRING_VERT;
     public static final int TOP_LEFT;
     public static final int TOP_RIGHT;
     public static final int WEST;

          // Constructors 1
     public StrutLayout();

          // Methods 19
     public static void addStruts(Container, StrutLayout.Strut[]);
     public static int getDefaultStrutLength();
     public static void setDefaultStrutLength(int);

     public void addLayoutComponent(Component, Object);
     public void addLayoutComponent(String, Component);
     public StrutLayout.SizeGroup createSizeGroup();
     public int getAlignment();
     public float getLayoutAlignmentX(Container);
     public float getLayoutAlignmentY(Container);
     public StrutLayout.SizeGroup getSizeGroup(Component);
     public void invalidateLayout(Container);
     public void layoutContainer(Container);
     public Dimension maximumLayoutSize(Container);
     public Dimension minimumLayoutSize(Container);
     public Dimension preferredLayoutSize(Container);
     public void removeLayoutComponent(Component);
     public void setAlignment(int);
     public void setPreferredSize(Component, Dimension);
     public void setSprings(Component, int);

          // Inner Classes 4
     public final class StrutLayout.SizeGroup
     public static final class StrutLayout.Strut
     public static final class StrutLayout.StrutConstraint
     public static final class StrutLayout.VectorConstraint
}

StrutLayout is an AWT layout manager that lays out components by logically connecting them with struts. Each StrutLayout has a root component which any number of child components may connect to. Each child component may have also have child components, and so on.

Each component in a StrutLayout may also have internal springs associated with it. These springs can be used to make the component expand horizontally and/or vertically to take up any extra space. The expansion takes into account any child components, ensuring they are not pushed off the edge of the layout area.

Additionally, each component may be a member of a size group which allows sets of components to maintain the same horizontal and/or vertical dimensions as the largest component in the group.

NOTE: although AWT layout managers are in theory able to layout more than container simultaneously, StrutLayout will get very confused if you try to use it like this. For now, you need to use one instance of StrutLayout per container.

Version:
1.1 ($Revision: 1.17 $)
Author:
Matthew Phillips mpp@ozemail.com.au

See Also: StrutLayout.StrutConstraint, StrutLayout.VectorConstraint, setSprings, createSizeGroup




  Fields

· TOP_LEFT

Summary  |  Top

   public static final int TOP_LEFT

Represents the top left corner of a rectangle.


· MID_TOP

Summary  |  Top
   public static final int MID_TOP

Represents the middle of the top side of a rectangle.


· TOP_RIGHT

Summary  |  Top
   public static final int TOP_RIGHT

Represents the top right corner of a rectangle.


· MID_RIGHT

Summary  |  Top
   public static final int MID_RIGHT

Represents the middle of the right side of a rectangle.


· BOTTOM_RIGHT

Summary  |  Top
   public static final int BOTTOM_RIGHT

Represents the bottom right corner of a rectangle.


· MID_BOTTOM

Summary  |  Top
   public static final int MID_BOTTOM

Represents the middle of the bottom side of a rectangle.


· BOTTOM_LEFT

Summary  |  Top
   public static final int BOTTOM_LEFT

Represents the bottom left corner of a rectangle.


· MID_LEFT

Summary  |  Top
   public static final int MID_LEFT

Represents the middle of the left side of a rectangle.


· CENTER

Summary  |  Top
   public static final int CENTER

Represents the center of a rectangle.


· NORTH

Summary  |  Top
   public static final int NORTH

Represents the direction towards the top of the screen.


· SOUTH

Summary  |  Top
   public static final int SOUTH

Represents the direction towards the bottom of the screen.


· EAST

Summary  |  Top
   public static final int EAST

Represents the direction towards the right of the screen.


· WEST

Summary  |  Top
   public static final int WEST

Represents the direction towards the left of the screen.


· NORTH_EAST

Summary  |  Top
   public static final int NORTH_EAST

Represents the direction towards the top right of the screen.


· SOUTH_EAST

Summary  |  Top
   public static final int SOUTH_EAST

Represents the direction towards the bottom right of the screen.


· SOUTH_WEST

Summary  |  Top
   public static final int SOUTH_WEST

Represents the direction towards the bottom left of the screen.


· NORTH_WEST

Summary  |  Top
   public static final int NORTH_WEST

Represents the direction towards top left of the screen.


· SPRING_NONE

Summary  |  Top
   public static final int SPRING_NONE

Specifies a non-existent spring.


· SPRING_HORIZ

Summary  |  Top
   public static final int SPRING_HORIZ

Specifies a spring that expands horizontally.


· SPRING_VERT

Summary  |  Top
   public static final int SPRING_VERT

Specifies a spring that expands vertically.


· SPRING_BOTH

Summary  |  Top
   public static final int SPRING_BOTH

Specifies a spring that expands both horizontally and vertically.


· SIZE_WIDTH

Summary  |  Top
   public static final int SIZE_WIDTH

Specifies a member of a size group whose width is tied to the group's width.


· SIZE_HEIGHT

Summary  |  Top
   public static final int SIZE_HEIGHT

Specifies a member of a size group whose height is tied to the group's height.


· SIZE_BOTH

Summary  |  Top
   public static final int SIZE_BOTH

Specifies a member of a size group whose width and height are tied to the group's size.


· SIZE_NONE

Summary  |  Top
   public static final int SIZE_NONE

Specifies a member of a size group who participates in setting the group's size but which does not change size itself.


  Constructors

· StrutLayout

Summary  |  Top

   public StrutLayout() 


  Methods

· setAlignment

Summary  |  Top
   public void setAlignment(int alignment) 

Sets the alignment of the layout area within the container (the default is CENTER). This only has effect when the components managed by the layout do not use all the space in the container.

Parameter Description
alignment The alignment of the layout area within the container. One of TOP_LEFT, MID_TOP, TOP_RIGHT, MID_RIGHT, BOTTOM_RIGHT, MID_BOTTOM, BOTTOM_LEFT, MID_LEFT or CENTER (the default).

See Also: getAlignment



· getAlignment

Summary  |  Top
   public int getAlignment() 

Returns the current alignment the layout area within the container (see setAlignment() for details).

Returns:
The current alignment of components within the layout area.

See Also: setAlignment



· setSprings

Summary  |  Top
   public void setSprings(Component component, 
                          int springs) 

Sets internal springs on a component which act to expand the component horizontally and/or vertically to fill empty space. Child components are pushed as far down/right as they can go without pushing them off the container.

NOTE: while child components are protected from being covered by their sprung parent components, this does not prevent others not connected to the parent from being potentially obscured. It is up to you to ensure the layout rules do not allow this.

Example:

  strutLayout.setSprings (tablePane, StrutLayout.SPRING_BOTH);
  

Parameter Description
component The component to add the spring to. The component must already be a part of the layout
springs The spring(s) to add to the component. One of SPRING_NONE, SPRING_HORIZ, SPRING_VERT or SPRING_BOTH.

See Also: SPRING_NONE, SPRING_VERT, SPRING_HORIZ, SPRING_BOTH



· createSizeGroup

Summary  |  Top
   public StrutLayout.SizeGroup createSizeGroup() 

Creates a new group of components whose sizes are tied together. See StrutLayout.SizeGroup for a full description.

Returns:
A new size group object.

See Also: StrutLayout.SizeGroup, getSizeGroup



· getSizeGroup

Summary  |  Top
   public StrutLayout.SizeGroup getSizeGroup(Component component) 

Returns the size group that a component is a member of.

Parameter Description
component The component to be queried.

Returns:
The size group the component is a member of or null if the component is not a member of a group.

See Also: StrutLayout.SizeGroup, createSizeGroup



· getDefaultStrutLength

Summary  |  Top
   public static int getDefaultStrutLength() 

Returns the current default length for struts. This setting is global to all instances of StrutLayout.

Returns:
Returns the current default length.

See Also: setDefaultStrutLength, StrutLayout.StrutConstraint, StrutLayout.Strut



· setDefaultStrutLength

Summary  |  Top
   public static void setDefaultStrutLength(int length) 

Sets the current default length for struts. This setting is global to all instances of StrutLayout.

See Also: getDefaultStrutLength, StrutLayout.StrutConstraint, StrutLayout.Strut



· setPreferredSize

Summary  |  Top
   public void setPreferredSize(Component component, 
                                Dimension preferredSize) 

Fixes the preferred size for a component regardless of what its getPreferredSize () method returns. A component's preferred size can also be fixed in this way by sizing it to a non-zero area (via setSize ()) before adding it to the layout.

Parameter Description
component The component whose preferred size is to be fixed.
preferredSize The new preferred size of the component. If this is null, then the component's preferred size reverts to the result of its getPreferredSize () method.

See Also: addLayoutComponent



· addStruts

Summary  |  Top
   public static void addStruts(Container container, 
                                StrutLayout.Strut[] struts) 

Adds a number of struts to the layout at once. This is a convenient shortcut which is equivalent to a series of Component.add (...) calls.

Parameter Description
struts The struts to be added.

See Also: StrutLayout.Strut, addLayoutComponent



· addLayoutComponent

Summary  |  Top
   public void addLayoutComponent(String name, 
                                  Component component) 

Does nothing. Use addLayoutComponent (Component, Object) instead.

See Also: addLayoutComponent



· removeLayoutComponent

Summary  |  Top
   public void removeLayoutComponent(Component component) 

Removes a component from a layout. This also removes all child components connected by struts.

Parameter Description
component The component to remove.

See Also: addLayoutComponent



· addLayoutComponent

Summary  |  Top
   public void addLayoutComponent(Component component, 
                                  Object constraintObject) 

Adds a component to the layout, possibly using a strut as the constraint. Using null as the constraint indicates the component is the root component (of which there may only be one).

NOTE: If the component has a non-zero size when added, this size will be used as its preferred size rather than the result of its getPreferredSize () method.

Parameter Description
component The component to add.
constraintObject The constraint to use when laying out the component. This may be an instance of either StrutLayout.StrutConstraint or StrutLayout.VectorConstraint or null for the root component.

Implements:
addLayoutComponent in interface LayoutManager2

See Also: StrutLayout.StrutConstraint, StrutLayout.VectorConstraint, setPreferredSize



· getLayoutAlignmentX

Summary  |  Top
   public float getLayoutAlignmentX(Container parent) 
Implements:
getLayoutAlignmentX in interface LayoutManager2


· getLayoutAlignmentY

Summary  |  Top
   public float getLayoutAlignmentY(Container parent) 
Implements:
getLayoutAlignmentY in interface LayoutManager2


· maximumLayoutSize

Summary  |  Top
   public Dimension maximumLayoutSize(Container parent) 
Implements:
maximumLayoutSize in interface LayoutManager2


· minimumLayoutSize

Summary  |  Top
   public Dimension minimumLayoutSize(Container parent) 


· preferredLayoutSize

Summary  |  Top
   public Dimension preferredLayoutSize(Container parent) 


· layoutContainer

Summary  |  Top
   public void layoutContainer(Container parent) 


· invalidateLayout

Summary  |  Top
   public void invalidateLayout(Container parent) 
Implements:
invalidateLayout in interface LayoutManager2


All Packages  This Package  Class Hierarchy  Class Search  Index
Freshly brewed Java API Documentation automatically generated with polardoc Version 1.0.7