All Libraries | This Library | Package | Class | Use | Tree | Deprecated | Index | Grand Index | Help
|  | Components |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sas.swing.visuals.wizard
Class ButtonLayout

    com.sas.swing.visuals.wizard.ButtonLayout

All Implemented Interfaces:
  java.awt.LayoutManager, java.awt.LayoutManager2

    public class ButtonLayout

implements java.awt.LayoutManager2

A layout manager for a container that lays out components in a single horizontal row, allowing components to specify the amount of space to place to the right of themselves. This space can be specified as a fixed amount (in number of pixels), a percentage of the leftover space, or the remainder of leftover space. The components are laid out according to their preferred sizes, and are centered within the container's vertical space.

After space is given to components requesting fixed space, any leftover space is divided among components requesting a percentage, and/or the remainder of this space. First, components requesting a percentage are given space, followed by the component requesting the remainder receiving the rest for placement to its right. Only one component may request the remainder.

If no component requests the remaining space, then leftover space will be used to justify the buttons to the left or right side of the container. If the buttons are right justified, then remaining space left after button spacing requests are made is placed to the far left, before any buttons are layed out. If left justified, the buttons are layed out first following the left insets, and any remaining space is placed to the far right.

The default behavior is to justify the components to the right, assuming no component requests the remainder space. If a component has requested the remainder space, then setting the justification will have no effect. The justification can be set by invoking the `setJustification` method.

A `ButtonLayout` layout manager object cannot be shared among containers.

When adding a component to a container with a button layout, use one of these alternatives:

To place a fixed amount of space to the right of the component:

        Panel p = new Panel();
        p.setLayout(new ButtonLayout());
        p.add(new Button("Cancel"), new Integer(10));//Puts 10 pixels of space to right of this component

To place a percentage of any remaining space to the right of the component:

        Panel p = new Panel();
        p.setLayout(new ButtonLayout());
        p.add(new Button("Help"), new Float(.25));  //Puts 25% of leftover space to right of this component

One component in the container may claim any remaining space to the right of the component, for example:

        Panel p = new Panel();
        p.setLayout(new ButtonLayout());
        p.add(new Button("Quit"), ButtonLayout.REMAINDER);  //Puts leftover space to right of this component

ButtonLayout interprets the absence of a constraint specification the same as a request for fixed spacing of 0 pixels for placement to the right of the component:

        Panel p = new Panel();
        p.setLayout(new ButtonLayout());
        p.add(new Button("Next"));  // Same as p.add(new Button("Next"), new Integer(0) );

Field Summary
`protected int` | `justify` An int value indicating if the components are to be justified to the left or right within the container.
`static java.lang.String` | `RB_KEY`
`static java.lang.String` | `REMAINDER` The remainder layout constraint.
`protected java.awt.Component` | `remainderComponent` The component requesting the remainder of any leftover space
`protected float` | `remainingPercentSpace` Value representing percent of remainder space left available to components.
`protected java.util.Hashtable` | `rightSpaceTable` Holds a pixel value indicating how much space to layout to the right of each component depending on the current size of the parent container
`protected java.util.Hashtable` | `spaceRequestTable` Holds values that reflect the spacing requests for components.

Constructor Summary
`ButtonLayout()` Constructs a new button layout

Method Summary
`void` | `addLayoutComponent(java.awt.Component comp, java.lang.Object constraint)` Adds the specified component to the layout, using the specified constraint object.
`void` | `addLayoutComponent(java.lang.String string, java.awt.Component comp)` Adds the specified component with the specified string to the layout.
`java.lang.Object` | `getConstraint(java.awt.Component comp)` Returns the spacing constraint for a component, or null if the component is not found.
`float` | `getLayoutAlignmentX(java.awt.Container parent)` Returns the alignment along the x axis.
`float` | `getLayoutAlignmentY(java.awt.Container parent)` Returns the alignment along the y axis.
`void` | `invalidateLayout(java.awt.Container target)` Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
`void` | `layoutContainer(java.awt.Container parent)` Lays out the container argument using this button layout.
`java.awt.Dimension` | `maximumLayoutSize(java.awt.Container target)` Returns the maximum dimensions for this layout given the component in the specified target container.
`java.awt.Dimension` | `minimumLayoutSize(java.awt.Container parent)` Returns the minimum dimensions needed to layout the components contained in the specified panel.
`java.awt.Dimension` | `preferredLayoutSize(java.awt.Container parent)` Returns the preferred dimensions needed to layout the components contained in the specified panel.
`void` | `removeLayoutComponent(java.awt.Component comp)` Removes the specified component from this button layout.
`void` | `setConstraint(java.awt.Component comp, java.lang.Object constraint)` Sets the spacing constraint for a component.
`void` | `setJustification(int align)` Sets the Horizontal justification in the parent container.

Field Detail

### RB_KEY

    public static final java.lang.String RB_KEY

See Also:
  Constant Field Values

### REMAINDER

    public static final java.lang.String REMAINDER

  The remainder layout constraint. A component added with this constraint is requesting to have any remaining leftover space placed to its right.

  See Also:
    Constant Field Values

### spaceRequestTable

    protected java.util.Hashtable spaceRequestTable

  Holds values that reflect the spacing requests for components. Can be an Integer object holding a pixel value for fixed spacing, a Float object holding a decimal value for percentage spacing, or a String object equal to ButtonLayout.REMAINDER indicating to use any remaining leftover space.

### rightSpaceTable

    protected java.util.Hashtable rightSpaceTable

  Holds a pixel value indicating how much space to layout to the right of each component depending on the current size of the parent container

### remainderComponent

    protected java.awt.Component remainderComponent

  The component requesting the remainder of any leftover space

### justify

    protected int justify

  An int value indicating if the components are to be justified to the left or right within the container. Valid values are Orientations.LEFT and Orientations.RIGHT. The default setting is Orientations.RIGHT.

  See Also:
    `setJustification(int)`

### remainingPercentSpace

    protected float remainingPercentSpace

  Value representing percent of remainder space left available to components.

Constructor Detail

### ButtonLayout

    public ButtonLayout()

  Constructs a new button layout

Method Detail

### addLayoutComponent

    public void addLayoutComponent(java.lang.String string,
                                   java.awt.Component comp)

  Adds the specified component with the specified string to the layout. By default, the addLayoutComponent method with an object constraint argument is called. The string is passed through directly. The only valid value for `string` is ButtonLayout.REMAINDER.

  Specified by:
    `addLayoutComponent` in interface `java.awt.LayoutManager`
  Parameters:
    `string` - a constraint specifying the amount of space to place to the right of the component
    `comp` - the component to be added

### addLayoutComponent

    public void addLayoutComponent(java.awt.Component comp,
                                   java.lang.Object constraint)

  Adds the specified component to the layout, using the specified constraint object.

  For components requesting fixed spacing to their right, `constraint` should be an Integer object, whose value is non-negative and represents the number of pixels to place to the right of the component.

  For components requesting a percentage of leftover space to their right, `constraint` should be a Float object. The valid range is between 0 and 1.0, where the value represents the percent of leftover space to place to the right of the component.

  For components requesting the remainder of leftover space, `constraint` should be a String equal to ButtonLayout.REMAINDER.

  An IllegalArgumentException is thrown for values outside of the above mentioned ranges on the Float and Integer constraints.

  Specified by:
    `addLayoutComponent` in interface `java.awt.LayoutManager2`
  Parameters:
    `comp` - the component to be added
    `constraint` - an Integer, Float, or String object which specifies the amount of space to place to the right of the component

### removeLayoutComponent

    public void removeLayoutComponent(java.awt.Component comp)

  Removes the specified component from this button layout. This method is called when a container calls its `remove` or `removeAll` methods.

  Specified by:
    `removeLayoutComponent` in interface `java.awt.LayoutManager`
  Parameters:
    `comp` - the component to be removed

### preferredLayoutSize

    public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)

  Returns the preferred dimensions needed to layout the components contained in the specified panel.

  Specified by:
    `preferredLayoutSize` in interface `java.awt.LayoutManager`
  Parameters:
    `parent` - the component which needs to be laid out
  See Also:
    `minimumLayoutSize(java.awt.Container)`

### minimumLayoutSize

    public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)

  Returns the minimum dimensions needed to layout the components contained in the specified panel.

  Specified by:
    `minimumLayoutSize` in interface `java.awt.LayoutManager`
  Parameters:
    `parent` - the component which needs to be laid out
  See Also:
    `preferredLayoutSize(java.awt.Container)`

### layoutContainer

    public void layoutContainer(java.awt.Container parent)

  Lays out the container argument using this button layout.

  Specified by:
    `layoutContainer` in interface `java.awt.LayoutManager`
  Parameters:
    `parent` - the specified component being laid out

### maximumLayoutSize

    public java.awt.Dimension maximumLayoutSize(java.awt.Container target)

  Returns the maximum dimensions for this layout given the component in the specified target container.

  Specified by:
    `maximumLayoutSize` in interface `java.awt.LayoutManager2`
  Parameters:
    `target` - The component which needs to be laid out

### getLayoutAlignmentX

    public float getLayoutAlignmentX(java.awt.Container parent)

  Returns the alignment along the x axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.

  Specified by:
    `getLayoutAlignmentX` in interface `java.awt.LayoutManager2`
  Parameters:
    `parent` - the specified component being laid out

### getLayoutAlignmentY

    public float getLayoutAlignmentY(java.awt.Container parent)

  Returns the alignment along the y axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.

  Specified by:
    `getLayoutAlignmentY` in interface `java.awt.LayoutManager2`
  Parameters:
    `parent` - the specified component being laid out

### invalidateLayout

    public void invalidateLayout(java.awt.Container target)

  Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.

  Specified by:
    `invalidateLayout` in interface `java.awt.LayoutManager2`

### setJustification

    public void setJustification(int align)

  Sets the Horizontal justification in the parent container. If the buttons are right justified, then remaining space left after button spacing requests are made is placed to the far left, before any buttons are layed out. If left justified, the buttons are layed out first following the left insets, and any remaining space is placed to the far right.

  If a button is already requesting the remainder space, then setting the justification has no affect.

  The default is set to Orientations.RIGHT.

  Parameters:
    `parent` - the specified component being laid out
    `align` - int representation of com.sas.geometry.Orientations. values can be either Orientations.LEFT, or Orientations.RIGHT.

### setConstraint

    public void setConstraint(java.awt.Component comp,
                              java.lang.Object constraint)

  Sets the spacing constraint for a component.

  Parameters:
    `parent` - the specified component being laid out
    `comp` - the component in the parent container to set the spacing constraint for
    `constraint` - an Integer, Float, or String object which specifies the amount of space to place to the right of the button

### getConstraint

    public java.lang.Object getConstraint(java.awt.Component comp)

  Returns the spacing constraint for a component, or null if the component is not found.

  Parameters:
    `comp` - the component in the parent container to get the spacing constraint for

All Libraries | This Library | Package | Class | Use | Tree | Deprecated | Index | Grand Index | Help
|  | Components |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2009 SAS Institute Inc. All Rights Reserved.